jQuery UI Widgets › Forums › DataTable › refresh cell value
Tagged: cellbeginedit, cellendedit, refresh
This topic contains 5 replies, has 2 voices, and was last updated by Peter Stoev 9 years, 10 months ago.
-
Authorrefresh cell value Posts
-
Hi,
I have read that some had the same problem , but i can’t find any solution here.
I want to refresh the value of particular cell.
From the documentation this should be done calling:$("#saleTable").jqxDataTable('beginCellEdit',rowIndex, 'total', true); $("#saleTable").jqxDataTable('endCellEdit',rowIndex, 'total', true);
The main funcationality is a table with ‘quantity’, ‘price’, ‘total’ fields.
I want when the quantity or the price cell is edited the total value to be updatted because total=quantity * price.This is:
$("#saleTable").on('cellEndEdit', function (event) { var args = event.args; // row key var rowKey = args.key; // row's index. var rowIndex = args.index; // row's data. var rowData = args.row; // row's index in the data source. var rowBoundIndex = args.boundIndex; // column's data field. var columnDataField = args.dataField; // column's display field. var columnDisplayField = args.displayField; // cell's value. var value = args.value; //log changed value $("#log").html(value); //update source if (columnDataField == 'quantity'){ data[rowBoundIndex].quantity = value; } if (columnDataField == 'prices'){ data[rowBoundIndex].prices = value; } else { //do nothing } data[rowBoundIndex].total = data[rowBoundIndex].quantity*data[rowBoundIndex].prices; $("#saleTable").jqxDataTable('beginCellEdit',rowIndex, 'total', true); $("#saleTable").jqxDataTable('endCellEdit',rowIndex, 'total', true); });
Hi cpuin,
“beginCellEdit” opens the editor. “endCellEdit” closes the editor. If you want to set value or update a row, read about “setCellValue” and “updateRow”.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comDear Peter,
updateRow requires new values! What i need is simply update the cell(if needed row) from the source
Hi cpuin,
Yes, it requires the Values which you want to put in the Row. That is what “updateRow” stands for. Pass the values from your data source.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks Peter!
I tought there is a shorter way to update all items from the source istead to bind each of them.
It works.Hi cpuin,
When there’s an update in the data source, you should notify the widget for that update. Usually, if you know what you update, you have to simply call setCellValue or updateRow, but if you do now know what’s updated in the data source, you can call updateBoundData which rebinds the widget and re-renders it.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.