Jump to content

Enable or disable action column


Lone Wolf

Recommended Posts

Hi, I've a question about DBGrid action column.

I've a DBGrid such the one I attach here.
As you can see I've a column (titled Certified) that show the content of a Boolean field in my database. The column at the right of this one is an action column. 

I would like to enable (eventually show or hide the image "Certify >" accordingly to the boolean field. Is this one is True I want to disable the action column; if False I want to enable it.
This must be done for each record in my grid. There is a way to reach this task?

Many thanks for your anser

Eros

 

DBGrid.jpg

Link to comment
Share on other sites

Hello,

16 minutes ago, Lone Wolf said:

I would like to enable (eventually show or hide the image "Certify >" accordingly to the boolean field. Is this one is True I want to disable the action column; if False I want to enable it.

 

This post may help you:

 

Link to comment
Share on other sites

Ok!

I attach a simple example.

I've a table with a field called "FlagActive" which is a boolean and other fields 
I've created a DBGrid with the two fields on my in memory table: the description and the flag field. In the DBGrid I've created also an action column with a button. 

I would like to have this button enabled in the FlagActive field is True and disable for the false value of this field so, in my case the third record button (Record number 3) should be disabled and (possibly) hide. How can I reach this?

Many thanks for your answer

Eros

App_002.zip

Link to comment
Share on other sites

1 hour ago, Lone Wolf said:

App_002.zip 99.65 kB · 0 downloads

Try this approach:

UniDBGrid1.ClientEvents.ExtEvents ->

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    dataColIndx = 1;
    actionColIndx = 2;
    actionItemsIndx = 0;
    
    columns[actionColIndx].items[actionItemsIndx].isActionDisabled = function (grid, rowIndex, colIndex, items, record) {
        return (record.data[dataColIndx] === false);
    };
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...