MarkB Posted March 3, 2020 Share Posted March 3, 2020 I'd like to have a ColumnWidget with a button but I need the buttons to be able to be disabled based upon a value in the row they are in. Link to comment Share on other sites More sharing options...
Sherzod Posted March 3, 2020 Share Posted March 3, 2020 35 minutes ago, MarkB said: I'd like to have a ColumnWidget with a button but I need the buttons to be able to be disabled based upon a value in the row they are in. function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var widgetColIndx=1; columns[widgetColIndx].onWidgetAttach = function(column, widget, record) { widget.setDisabled(record.get(widgetColIndx) == "Blue Angelfish"); }; } 1 Link to comment Share on other sites More sharing options...
MarkB Posted March 5, 2020 Author Share Posted March 5, 2020 On 3/3/2020 at 10:51 AM, Sherzod said: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var widgetColIndx=1; columns[widgetColIndx].onWidgetAttach = function(column, widget, record) { widget.setDisabled(record.get(widgetColIndx) == "Blue Angelfish"); }; } Thanks. This kind of works. If a round trip is made to the server and all rows are returned it works. But if you edit the row and change the value to a valid state, the state of the button does not change. Link to comment Share on other sites More sharing options...
Sherzod Posted March 5, 2020 Share Posted March 5, 2020 7 hours ago, MarkB said: But if you edit the row and change the value to a valid state, the state of the button does not change. Please explain. Link to comment Share on other sites More sharing options...
Yai_NP_TH Posted May 20, 2021 Share Posted May 20, 2021 function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var widgetColIndx=1; columns[widgetColIndx].onWidgetAttach = function(column, widget, record) { if (record.get(widgetColIndx) == "Blue Angelfish") { widget.setvisible(true); } else { widget.setvisible(false); }; }; } Link to comment Share on other sites More sharing options...
fraxzi Posted February 22, 2023 Share Posted February 22, 2023 Hi @Sherzod, I confirmed that: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var widgetColIndx = 2; columns[widgetColIndx].onWidgetAttach = function(column, widget, record) { widget.setDisabled(record.get(widgetColIndx) != "0"); }; } Doesn't work if dgbrid.Options.dgRowNumbers := true ... works only of set to false.. I need the row number. What is the alternative? I tried widgetColindx = 3 with row number but it didn't work as well. Thanks, Frances Link to comment Share on other sites More sharing options...
Sherzod Posted February 22, 2023 Share Posted February 22, 2023 19 minutes ago, fraxzi said: Doesn't work if dgbrid.Options.dgRowNumbers := true ... works only of set to false.. I need the row number. What is the alternative? Hello, Yes. Link to comment Share on other sites More sharing options...
Sherzod Posted February 22, 2023 Share Posted February 22, 2023 20 minutes ago, fraxzi said: I tried widgetColindx = 3 with row number but it didn't work as well. The reason it doesn't work: record.get(widgetColIndx) Link to comment Share on other sites More sharing options...
Sherzod Posted February 22, 2023 Share Posted February 22, 2023 28 minutes ago, fraxzi said: What is the alternative? Solution for both cases: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var delta=0; if (columns[0].xtype && columns[0].xtype == 'rownumberer') { delta = 1; } var widgetColIndx = 1; //Index without regard to rownumberer columns[widgetColIndx + delta].onWidgetAttach = function(column, widget, record) { widget.setDisabled(record.get(widgetColIndx) == "Blue Angelfish"); }; } 1 Link to comment Share on other sites More sharing options...
fraxzi Posted February 22, 2023 Share Posted February 22, 2023 29 minutes ago, Sherzod said: Solution for both cases: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var delta=0; if (columns[0].xtype && columns[0].xtype == 'rownumberer') { delta = 1; } var widgetColIndx = 1; //Index without regard to rownumberer columns[widgetColIndx + delta].onWidgetAttach = function(column, widget, record) { widget.setDisabled(record.get(widgetColIndx) == "Blue Angelfish"); }; } You're the Man! @Sherzod, Works superbly! Thanks much, Frances 1 Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted June 19, 2023 Share Posted June 19, 2023 @SherzodGood morning! Please, is there a possibility of leaving the button invisible instead of deactivating it? This topic helped me a lot, but my user wanted it to be invisible, if possible! Thank you for your attention! Link to comment Share on other sites More sharing options...
Sherzod Posted June 19, 2023 Share Posted June 19, 2023 Hello, 34 minutes ago, sicoobcooplivre said: Please, is there a possibility of leaving the button invisible instead of deactivating it? This topic helped me a lot, but my user wanted it to be invisible, if possible! Thank you for your attention! Just use setHidden instead of setDisabled. Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted June 19, 2023 Share Posted June 19, 2023 Thank you very much! It worked out! Great week! Link to comment Share on other sites More sharing options...
yakup Posted September 13, 2023 Share Posted September 13, 2023 On 3/3/2020 at 8:51 PM, Sherzod said: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var widgetColIndx=1; columns[widgetColIndx].onWidgetAttach = function(column, widget, record) { widget.setDisabled(record.get(widgetColIndx) == "Blue Angelfish"); }; } Thank you, it helped me a lot now 1 Link to comment Share on other sites More sharing options...
fraxzi Posted January 18 Share Posted January 18 On 2/22/2023 at 12:56 PM, Sherzod said: Solution for both cases: function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var delta=0; if (columns[0].xtype && columns[0].xtype == 'rownumberer') { delta = 1; } var widgetColIndx = 1; //Index without regard to rownumberer columns[widgetColIndx + delta].onWidgetAttach = function(column, widget, record) { widget.setDisabled(record.get(widgetColIndx) == "Blue Angelfish"); }; } Hi @Sherzod, I tried this solution with Grouped dbGrid and I couldn't make it work like the one Not Grouped. Any suggestion? Thanks, Frances Link to comment Share on other sites More sharing options...
Sherzod Posted January 18 Share Posted January 18 Hello @fraxzi Yes, you need to modify the code for this, there are several examples on the forum using the reconfigure function that can help you. You can analyze these examples and apply them in your project, I'll try later. Link to comment Share on other sites More sharing options...
fraxzi Posted January 22 Share Posted January 22 On 1/18/2024 at 12:16 PM, Sherzod said: Hello @fraxzi Yes, you need to modify the code for this, there are several examples on the forum using the reconfigure function that can help you. You can analyze these examples and apply them in your project, I'll try later. Hi @Sherzod, I looked at all available post but still couldn't figure it out. Could you help me out please. Thanks, Frances Link to comment Share on other sites More sharing options...
Sherzod Posted January 22 Share Posted January 22 Hello @fraxzi I'll try, but you might also find this post helpful: Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now