jQuery UI Widgets › Forums › Grid › Update Value in grid
This topic contains 3 replies, has 2 voices, and was last updated by Dimitar 10 years, 9 months ago.
-
AuthorUpdate Value in grid Posts
-
Hello there,
When i send and updaterow fun ction in grid, my row object is changing and return all field values the selected row.
See on my code below, my console.log of row got the good value in grid but the console.log in updaterow function return all data instead of the one i want.
Here a sample of my code:var WLentries = { datatype: "json", datafields: [ { name: <em>.... here all my fields .....</em> type: 'string'}, ], id: 'WL_NUMBER', url: 'MyUrl/query.php?query=showWLentries&HOSPITALNO='+HospitalNo, updaterow: function (rowid, rowdata, commit) { console.log(rowdata); <------------- Console Log in update function var data = "query=updateWL&rowname=" + rowdata.LISTE; data = data + "&id=" +rowid; $.ajax({ dataType: 'json', url: 'MyUrl/SqlDataModification.php', data: data, success: function (data, status, xhr) { commit(true); }}) } }; var WLData = new $.jqx.dataAdapter(WLentries); $("#ResultGrid").jqxGrid( { source: WLData, width: 1500, columns: [ { text: 'LISTE', columntype: 'dropdownlist', datafield: 'LISTE', width: 200 , createeditor: function (row, cellvalue, editor) { editor.jqxDropDownList({ source: WLcodedata, displayMember:"WLdescr",placeHolder: ""}); } , cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { if (newvalue == "") return oldvalue; var row = { Change: column, value: newvalue}; var rowID = $('#ResultGrid').jqxGrid('getrowid'); console.log(row); <------------- Console Log in Grid $('#ResultGrid').jqxGrid('updaterow', rowID, row); } }, ], etc ...
Hello tompasto,
These variables (row and rowdata) are not the same, they have different scopes and values. The updaterow rowdata argument has all data of the edited row.
We suggest you create a global variable, which is visible in both functions. Set it in cellvaluechanging and then get it in updaterow.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Tx Dimitar,
Can you tell me so, what the grid call ‘updaterow’ is use for ^
Tx.Hi tompasto,
The updaterow callback function is used to synchronize with the server (send update command). Call commit with parameter true if the synchronization with the server is successful and with parameter false if the synchronization failed.
If it suits you, you can also use it as a general callback function after a row is updated.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.