Jump to content

Disable Column Widget Buttons by a row value


MarkB

Recommended Posts

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");
    };
}

 

  • Like 1
Link to comment
Share on other sites

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

  • 1 year later...
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

  • 1 year later...

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

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");
    };
}

 

  • Like 1
Link to comment
Share on other sites

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

  • Thanks 1
Link to comment
Share on other sites

  • 3 months later...

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.

image.thumb.png.2e74051ff6bd1275e48bf37036834c94.png

Link to comment
Share on other sites

  • 2 months later...
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 :)

  • Thanks 1
Link to comment
Share on other sites

  • 4 months later...
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

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...