How to prevent table from refreshing when clicking on edit button with usego?
How to prevent table from refreshing when clicking on edit button with usego?
usego function or method in the context of Refine or Ant Design. It's possible there may be a typo or misunderstanding in your question. useEditableTable hook in Refine with Ant Design, this hook allows you to make a table row editable. You can control the editing state of a row by using the setId function that returns from useEditableTable. This function can be used to put a line to edit mode whenever it's clicked on. Here's an example:handleEventClick function, you're using the useGo hook from Refine to navigate to the edit view of a specific job. When you save or close the record, it's likely that you're being redirected back to the calendar view, which causes the calendar to reset.keepQuery: true option in your go function call is supposed to keep the query parameters in the URL when navigating. However, if the edit view doesn't have any query parameters that affect the state of the calendar, the calendar will still reset.useQuery hook that you can use to read and manipulate the URL query parameters. This can be used to store the state of the calendar in the URL and read it when rendering the calendar.useQuery hook:date query parameter to store the currently viewed date, and then use this date when rendering the calendar. You would need to update this query parameter whenever the date changes, and you might need to use the FullCalendar API to achieve this.useQuery hook with FullCalendar. You might need to refer to the documentation of FullCalendar and Refine for more information on how to use the useQuery hook and the FullCalendar API.useQuery hook. I apologize for the incorrect information.useShow, useTable, and useGo. These hooks can infer parameters from the current URL and update the URL if these parameters change. However, they might not provide the level of control needed to manipulate the URL query parameters directly.useShow hook can infer resource and id parameters from the current URL, and the useTable hook can infer resource, pagination, filters, and sorters parameters from the current route, and update the current route if any of these parameters changes.useLocation and useHistory hooks or equivalent hooks from the routing library you're using.usegouseEditableTableuseEditableTablesetIdhandleEventClickuseGouseGokeepQuery: truegodateuseTableuseTablesortersuseLocationuseHistoryimport { List, TextField, useEditableTable } from "@refinedev/antd";
import { Table, Form, Input } from "antd";
export const PostList: React.FC = () => {
const { tableProps, formProps, isEditing, setId } = useEditableTable<IPost>();
return (
<List>
<Form {...formProps}>
<Table
{...tableProps}
key="id"
onRow={(record) => ({
onClick: (event: any) => {
if (event.target.nodeName === "TD") {
setId && setId(record.id);
}
},
})}
>
<Table.Column key="id" dataIndex="id" title="ID" />
<Table.Column<IPost>
key="title"
dataIndex="title"
title="Title"
render={(value, data: any) => {
if (isEditing(data.id)) {
return (
<Form.Item name="title" style={{ margin: 0 }}>
<Input />
</Form.Item>
);
}
return <TextField value={value} />;
}}
/>
</Table>
</Form>
</List>
);
}; const handleEventClick = (clickInfo) => {
go({
to: {
resource: "jobs",
action: "edit",
id: clickInfo.event.id,
},
options: {
keepQuery: true,
},
type: "replace",
});
};import { useQuery } from "@refinedev/core";
// Inside your component
const { setQuery, query } = useQuery();
// To set a query parameter
setQuery("date", "2022-01-01");
// To read a query parameter
const date = query.date;import { useShow } from "@refinedev/core";
export const ShowPage = () => {
const { queryResult } = useShow();
const { data, isLoading } = queryResult;
if (isLoading) {
return <>Loading...</>;
}
return <>{data?.data.name}</>;
};