jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Change properties of columntype: 'button' dynamically
Tagged: Button, buttonclick, column, columntype, disable, grid, jqxgrid
This topic contains 2 replies, has 2 voices, and was last updated by andy8 10 years, 2 months ago.
-
Author
-
Hello everyone,
I need to enable/disable grid buttons (columntype: ‘button’) depending on the value of another cell of the same row dynamically. In other words, when I change some cell value, the column button should become enabled or disabled depending on the edited cell value.
How can I achieve this?
Thanks
Hello andy8,
Column buttons cannot be visually disabled but you can disable their functionality by checking for your condition in the buttonclick callback function, e.g.:
$("#jqxgrid").jqxGrid( { width: 850, source: dataAdapter, pageable: true, autoheight: true, columns: [ { text: 'First Name', datafield: 'firstname', width: 200 }, { text: 'Last Name', datafield: 'lastname', width: 200 }, { text: 'Product', datafield: 'productname', width: 190 }, { text: 'Quantity', datafield: 'quantity', width: 90, cellsalign: 'right' }, { text: 'Price', datafield: 'price', width: 90, cellsalign: 'right', cellsformat: 'c2' }, { text: 'Edit', datafield: 'Edit', columntype: 'button', cellsrenderer: function () { return "Edit"; }, buttonclick: function (row) { var currentQuantity = $('#jqxgrid').jqxGrid('getcellvalue', row, "quantity"); if (currentQuantity < 10) { // open the popup window when the user clicks a button. editrow = row; var offset = $("#jqxgrid").offset(); $("#popupWindow").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60} }); // get the clicked row's data and initialize the input fields. var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); $("#firstName").val(dataRecord.firstname); $("#lastName").val(dataRecord.lastname); $("#product").val(dataRecord.productname); $("#quantity").jqxNumberInput({ decimal: dataRecord.quantity }); $("#price").jqxNumberInput({ decimal: dataRecord.price }); // show the popup window. $("#popupWindow").jqxWindow('open'); } } } ] });
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Thank you, Dimitar!
-
AuthorPosts
You must be logged in to reply to this topic.