- Home
- Forum
- JavaScript - EJ 2
- How to get toolbar button state? disabled allways return false
How to get toolbar button state? disabled allways return false
Hi,
ive generated table like this:
var mygrid = new Grid({
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal', newRowPosition: 'Bottom'},
toolbar: ['Add', 'Delete', 'Update', 'Cancel'],
toolbarClick: mygridToolbarClickHandler,
columns: [
{
field: 'OrderID', isPrimaryKey: true, headerText: 'Order ID', textAlign: 'Right',
validationRules: { required: true, number: true }, width: 140
},
{
field: 'CustomerID', headerText: 'Customer ID',
validationRules: { required: true }, width: 140
},
],
});
mygrid.appendTo('#mygridContainer');
function mygridToolbarClickHandler(args){
console.log(args.item.disabled);
}
and args.item.disabled allways return false :/
i want correlate some button disabled state with add button disabled state
Please help.
SIGN IN To post a reply.
5 Replies
1 reply marked as answer
BS
Balaji Sekar
Syncfusion Team
October 12, 2020 03:57 PM UTC
Hi Tomasz,
Greetings from the Syncfusion support.
Before proceeding your query, we need to confirm that you want disable the toolbar items or access the disable toolbar items in the Grid’s toolbar.
For your convenience, we have shared documentation with toolbar item enable/disable action and custom toolbar items binding in the Grid’s toolbar.
Help Documentation: https://ej2.syncfusion.com/documentation/grid/tool-bar/#enabledisable-toolbar-items
If we misunderstood requirement, please share your exact requirement to us that will help to validate further.
Regards,
Balaji Sekar
TO
Tomasz
October 14, 2020 03:27 PM UTC
Its simply,
i want to get state of toolbar "add" button.
I can switch state by command from documentation like :
grid.toolbarModule.enableItems(['Grid_Collapse', 'Grid_Expand'], true);// enable toolbar items.But when
function toolbarClickHandler(args) {
// console.log ('toolbarClickHandler');
console.log(args);
in args array in disabled parameter is always "false"
I have grid as part of form and i want to disable subbmit button when grid add button is disabled.
BS
Balaji Sekar
Syncfusion Team
October 15, 2020 03:13 PM UTC
Hi Tomasz,
Thanks for your update.
We have validated your query with provided the information and we suspect that you want enable/disable the custom toolbar item(“Submit”) based on “Add” toolbar item state.
Please refer the below code example and sample for more information.
|
[index.js]
grid.toolbarClick = function(args) {
if (this.toolbarModule.toolbar.tbarEle[0].title == "Add") {
var addState =
this.toolbarModule.toolbar.tbarEle[0].getAttribute("aria-disabled") ==
"true"
? true
: false;
this.toolbarModule.enableItems(["submit"], addState); // enable/disable custom toolbar items.
}
}; |
Sample link: https://stackblitz.com/edit/mbc7fh-vpvmn2
Please get back to us, if you need further assistance.
Regards,
Balaji Sekar
Marked as answer
TO
Tomasz
October 21, 2020 12:44 PM UTC
Hi.
it works.
Thank You :)
BS
Balaji Sekar
Syncfusion Team
October 22, 2020 05:41 AM UTC
Hi Tomasz,
We glad that your issue has been fixed.
Please get back to us if you require further other assistance from us.
Regards,
Balaji Sekar.
SIGN IN To post a reply.