最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - How to serialize Datagrid mui x - Stack Overflow

programmeradmin2浏览0评论

My datagrid from mui x has formField. i use hookform and zod for handling form.

in order to be compatible with hookform i add

const { fields, append, remove } = useFieldArray({ control, name: "estimateItems", }); console.log("fields", fields);

for adding and removing rows ` const incrementTableRow = () => { console.log("incremented");

append({
  itemId: "",
  taxIds: [], // Default value for taxIds
  description: "",
  quantity: 0,
  price: 0,
  discount: 0,
  isDiscountPercentage: false,
  amount: 0,
  rowIndex: fields.length + 1,
});

};

const decrementTableRow = (data) => { console.log("delete", data);

remove(data.row.rowIndex);

};`

issue is i cant handle serailize rows prorperly.

this is columns obj ` { field: "rowIndex", headerName: "#", width: 40, align: "center", headerAlign: "center", // flex: 1, renderCell: (params) => { console.log("#", params);

      return params.value;
    },
  },`

i try to handle it rendercell but couldnt yet. maybe someone faced similar issue

发布评论

评论列表(0)

  1. 暂无评论