jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Grid updation is not working properly after deleting a row.
This topic contains 5 replies, has 3 voices, and was last updated by otonksaz 10 years, 2 months ago.
-
Author
-
Hi,
I have migrated to jqwidgets-ver2.9.2. and after migration I am facing an issue in my grid updation.
As I have a grid with 1 row in it by default and each row has a column with combobox. On selecting an item from combobox other column of the grid row, get filled by the value that are fetched from database in respect of the selected item.
Now :-
Step 1- If I select an item in the first row, the row is getting updated properly in respect of the item selected.
Step 2- Now I add another row by addrow function in the grid.But this time I didn’t select any item from the combobox. This means I have two row in the grid one with data and one without data.
Step 3- Now delete the 1st row from the grid by delete row function.
Step 4 – Then if I select any item now from the combobox for the second row its not getting updated as the first row was.
Please guide me what is the reason behind it I have checked that the data from database is fetched properly and also getting store in the variable but still the row is not getting updated.
Thanks & Regards.
Apeksha
Hi Apeksha,
From the provided explanation I cannot tell what is wrong and whether this is an issue on our side or in your code. Please, post a sample which demonstrates your scenario and we will be able to test locally. Btw. the current version is 3.0.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter Stoev,
This my code in which after deleting a row from grid the updaterow function is not working properly.
var debit_editrow;$("#ob_debit_grid").bind('cellclick', function (event) { debit_editrow = event.args.rowindex; });var source_debit = { datatype: "json", localdata: debit_account_list, datafields: [{ name: 'check', type: 'string' }, { name: 'opening_balance', type: 'float' }], id: 'id', // url: url, root: 'data', addrow: function (rowid, rowdata, position, commit) { // 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 failder. commit(true); }, deleterow: function (rowid, commit) { // synchronize with the server - send delete command // call commit with parameter true if the synchronization with the server is successful //and with parameter false if the synchronization failed. commit(true); } }; var dataAdapter_debit = new $.jqx.dataAdapter(source_debit); // initialize jqxGrid $("#ob_debit_grid").jqxGrid({ width: '40%', source: dataAdapter_debit, theme: 'shinyblack', autoheight: true, altrows: true, //enabletooltips: true, showaggregates: true, showstatusbar: true, statusbarheight: 0, editable: true, columns: [ { text: 'Account', columntype: 'combobox', datafield: 'check', createeditor: function (row, column, editor) { // assign a new data source to the combobox. var account = dc_account2; editor.jqxComboBox({ source: account, selectedIndex: 0 }); $(editor).on('open', function (event) { //changed from change to open event so that no event get fired unless dropdown is open.. $(editor).on('select', function (event) { //changed from select to change event on select event even on clicking this combobox event was firing... var args = event.args; if (args) { var item = args.item; var item_id = null; item_id = item.label; // console.log(item_id); //code to fetch and populate the row for selected item... if ((item_id !== undefined) && (item_id !== -1)) { for (var s = 0; s < displayed_charts_list2.length; s++) { var debit_balance = {}; if (displayed_charts_list2[s].check == item_id) { debit_balance.opening_balance = displayed_charts_list2[s].opening_balance; //console.log(displayed_charts_list2[s]["opening_balance"]); var opening_balance_value = { opening_balance: debit_balance.opening_balance }; $('#ob_debit_grid').jqxGrid('updaterow', debit_editrow, opening_balance_value); } } } } }); }); }, width: '55%' }, { text: 'Debit', datafield: 'opening_balance', cellsformat: 'f2', cellsalign: 'right', width: '45%' } ], ready: function () { var amount_aggregates = $("#ob_debit_grid").jqxGrid('getcolumnaggregateddata', 'opening_balance', ['sum']); $('#debit_total_amount').val(amount_aggregates.sum.toFixed(2)); } });//To delete $("#ob_debit_deleterow").bind('click', function () { var selectedrowindex = $("#ob_debit_grid").jqxGrid('getselectedrowindex'); var rowscount = $("#ob_debit_grid").jqxGrid('getdatainformation').rowscount; if (rowscount > 1) { if (selectedrowindex >= 0 && selectedrowindex < rowscount) { var id = $("#ob_debit_grid").jqxGrid('getrowid', selectedrowindex); var commit = $("#ob_debit_grid").jqxGrid('deleterow', id); var amount_aggregates = $("#ob_debit_grid").jqxGrid('getcolumnaggregateddata', 'opening_balance', ['sum']); $('#debit_total_amount').val(amount_aggregates.sum.toFixed(2)); } } });
Please guide me regarding this.
Thanks & Regards,
ApekshaHi Apeksha,
“updaterow” works with Row ID, not row indexes. You can get the Row ID by using the “getrowid” method. In addition, you may try the new version – jQWidgets 3.0.1.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter Stoev,
Thanks for your response it resolved my issue.
Thanks & Regards,
ApekshaHi Apeksha Singh,
I hava same issue.
Excuse me, but how did you solved it? -
AuthorPosts
You must be logged in to reply to this topic.