Jump to content

Any idea about ActionColumn Button hide or show ?


zhyhero

Recommended Posts

33 minutes ago, Sherzod said:

OnFormCreate ?

1. 

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  //conditions... True or False
  UniDBGrid1.JSInterface.JSAssign('isExcluded', [True]);
end;

2. 

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    columns[6].items[0].getClass = function (v, metadata, record) {
        if (sender.isExcluded) {
            return 'x-hidden'
        } else {
            return 'x-uni-action-cls';
        }
    };
}

 

Link to comment
Share on other sites

1 hour ago, Sherzod said:

1. 


procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  //conditions... True or False
  UniDBGrid1.JSInterface.JSAssign('isExcluded', [True]);
end;

2. 


function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    columns[6].items[0].getClass = function (v, metadata, record) {
        if (sender.isExcluded) {
            return 'x-hidden'
        } else {
            return 'x-uni-action-cls';
        }
    };
}

 

In this command can I pass which icon do I want to disable?

UniDBGrid1.JSInterface.JSAssign ('isExcluded', [True]);

Link to comment
Share on other sites

1 hour ago, eduardosuruagy said:

In this command can I pass which icon do I want to disable?

Approximate solution...

procedure TMainForm.UniFormReady(Sender: TObject);
begin
  with UniDBGrid1 do
  begin
    //first btn
    JSInterface.JSCode(#1'.columnManager.columns[6].items[0].getClass = function(v, metadata, record) {'+
      '    return "x-hidden"'+
      '};');

    //second btn
    JSInterface.JSCode(#1'.columnManager.columns[6].items[1].getClass = function(v, metadata, record) {'+
      '    return "x-hidden"'+
      '};');
  end;
end;

 

Link to comment
Share on other sites

On 10/30/2020 at 5:35 PM, Sherzod said:

Approximate solution...


procedure TMainForm.UniFormReady(Sender: TObject);
begin
  with UniDBGrid1 do
  begin
    //first btn
    JSInterface.JSCode(#1'.columnManager.columns[6].items[0].getClass = function(v, metadata, record) {'+
      '    return "x-hidden"'+
      '};');

    //second btn
    JSInterface.JSCode(#1'.columnManager.columns[6].items[1].getClass = function(v, metadata, record) {'+
      '    return "x-hidden"'+
      '};');
  end;
end;

 

Sorry for my insistence, but I couldn't get it to work, here is an example I did.

DbGrid.rar

Link to comment
Share on other sites

1 hour ago, eduardosuruagy said:

Sorry for my insistence, but I couldn't get it to work, here is an example I did.

Yes sorry, you are using the dgCheckSelect option, so the columns are renumbered +1

Use 

columnManager.columns[3]

instead of

columnManager.columns[2]

Link to comment
Share on other sites

  • 1 year later...
On 2/13/2019 at 5:45 AM, Sherzod said:

OK,

You can try to use getClass config

1. In DesignTime:

YourActionColumnButton -> ImageIndex = -1

2. UniDBGrid -> ClientEvents -> ExtEvents -> function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts):

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    dataColIndx = 0;
    actionColIndx = 6;
    actionItemsIndx = 0;
    
    columns[actionColIndx].items[actionItemsIndx].isActionDisabled = function (grid, rowIndex, colIndex, items, record) {
        return (record.data[dataColIndx] > 1500);
    };
    
    columns[actionColIndx].items[actionItemsIndx].getClass = function(value, metadata, record) {
        if (record.data[dataColIndx] > 1500) {
            return "x-fa fa-home"
        }
        else {
            return "x-fa fa-user"
        }
    };
}

ActionIconCls.png.1f570d676aeb6e1ed8cdc450d8f19a48.png

 

Hi Sherzod!!!

How do I put colors in -> return "x-fa fa-home"

Link to comment
Share on other sites

  • 1 month later...

Hello!

Some question.

In my UniDBGrid exist fields with values 0,1 or 2.

Also, in UniDBGrid exist column with ActionColumn[6] with one button.

What I want? I want that if in value at my field = 1 then Button in ActionColumn[6] will be Disabled or Hide for row.

I add code:

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    if (columns[0].xtype && columns[0].xtype == 'rownumberer') {
        columns[0].width = 55;
    }
    
    
    dataColIndx = 0;
    actionColIndx = 6;
    actionItemsIndx = 1;
    
    columns[actionColIndx].items[actionItemsIndx].isActionDisabled = function (grid, rowIndex, colIndex, items, record) {
        return (record.data[dataColIndx] = 1);
    }

}

But I get error:

image.png.392618e65ab250d587e7c6ffad678cce.png

 

I think, I'm wrong in count of column...

Just hide Button in ActionColumn[6], if value = 1 in my field...

Link to comment
Share on other sites

  • 1 year later...
On 2/13/2019 at 10:07 AM, Sherzod said:

Hi,

Can you try to use this approach for now?

UniDBGrid -> ClientEvents -> ExtEvents -> function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts):

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

 

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
   dataColIndx = sender.headerCt.findColumnIndex('CustNo');
   actionColIndx = 6;
   actionItemsIndx = 0;
    
   columns[actionColIndx].items[actionItemsIndx].isActionDisabled = function (grid, rowIndex, colIndex, items, record) {
        return (record.data[dataColIndx] > 1500);
    }
   
}

 

Приветствую! Как получить индекс по имени FieldName???

Link to comment
Share on other sites

One possible solution:

1. UniDBGrid.ClientEvents.ExtEvents ->

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    dataColIndx = 0;
    actionColIndx = 6;
    actionItemsIndx = 0;
    
    columns[actionColIndx].items[actionItemsIndx].getClass = function (value, metadata, record) {
        var cssColorClass = "";
        if (record.data[dataColIndx] >= 0 && record.data[dataColIndx] <= 1500) {
            cssColorClass = " greenColor"
        } else if (record.data[dataColIndx] > 1500) {
            cssColorClass = " orangeColor"
        }
        return columns[actionColIndx].items[actionItemsIndx].iconCls + " x-uni-action-cls" + cssColorClass;
    }
}

2. CustomCSS ->

.greenColor {
    color: green
}

.orangeColor {
    color: orange
}

 

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...