Reputation: 853
I am looking for inline editing a JQGrid.
My JQGrid having column like :
colModel: [
{ name: 'Model_ID', index: 'model_id', width: 100, editable: false, hidden:
false },
{ name: 'Cust_Nm', index: 'cust_nm', width: 100, editable: false},
{ name: 'Model_Nm', index: 'model_nm', width: 140, editable: false, },
{ name: 'Client_Nm1', index: 'client_nm1', width: 120, editable: true},
{ name: 'Client_Nm2', index: 'client_nm2', width: 120, editable: true},
{ name: 'Client_Nm3', index: 'client_nm3', width: 120, editable: true},
{ name: 'Date', index: 'regi_date', width: 130, editable:false, search: false }
],
cellEdit: true,
cellurl: '@Url.Action("UpdateJQGrid", "Config")',
cellsubmit: "remote"
I want to pass value of 'Model_ID' to "UpdateJQGrid" Controller method. UpdateJQGrid is getting called when I edit one cell and move the focus to other cell inside the jggrid. I have created a View Model and passing that ViewModel to the Controller Method. But I am getting only the edited value through ViewModel object not other values of the selected row. If I can get only the value of Model_ID in Controller method my requirement will be solved. Any help or hint is much appreciated.
Upvotes: 0
Views: 1228
Reputation: 222017
It's very important to understand that the implementation of jqGrid require to assign id
attribute to every row of the grid (to every <tr>
element of the <table>
with the main data). The documentation use rowid
as the value of id
attribute. If you use editing feature of jqGrid it's strictly recommended that you assign the value of id
attribute based on the native value which will be get from the database (existing on the backend side). The rowid
will be used in the most callbacks of jqGrid and will be post to the server during editing. Here you can read which information will be send to the server during cell editing.
If the values from Model_ID
(or model_id
) column are unique and the values come from the database than I would recommend you to use the value as the rowid
. To inform jqGrid to use the value you can either specify the corresponding value of id
property of jsonReader
(or xmlReader
). The value of id
property depends on the exact format of the data returned from the server, which you use to fill the grid. Another way will be to specify key: true
property in Model_ID
(model_id
) column. After the changes you will see that jqGrid will send the value from Model_ID
(model_id
) column to the server during cell editing. The value will be send as id=rowid
(as id
parameter). You can change the name of the parameter by usage prmNames: {id: "Model_ID"}
, for example, which changes id=rowid
to Model_ID=rowid
.
One more remark. I recommend you don't use index
property if it is not really required. If you miss the property then the value of name
property will be used instead. The usage of different values for name
and index
properties is the origin of many errors and makes impossible to use client side sorting, paging and filtering/searching.
Upvotes: 1