Jump to content

Any idea about ActionColumn Button hide or show ?


zhyhero

Recommended Posts

I have a ActionColumn (Unidbgrid) with 3 Buttons (Id 0,1,2).

When meet the condition 1 ,Button 0 and Button 1 show ,Button 2 hide.

When meet the condition 2,     Button 0 and Button 2 hide,Button 1 show.

when meet the condition 3,     Button 0 and Button 1 hide, Button 2,show.

What can I do ?

  • Like 1
Link to comment
Share on other sites

14 hours ago, zhyhero said:

Yes , of course

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

 

Link to comment
Share on other sites

15 hours ago, zhyhero said:

And another question ,can i change buttons imageindex dynamically ?

Can you try... ?

procedure TMainForm.UniButton1Click(Sender: TObject);
var
  ImgIndx,
  ActionColIndx,
  ActionItemIndx: Byte;
begin
  ImgIndx := 1;
  ActionColIndx := 6;
  ActionItemIndx := 0;

  with UniDBGrid1 do
  begin
    JSInterface.JSAssign(
            'icon',
            [UniNativeImageList1.GetImagePngUrl(ImgIndx)],
            //[UniNativeImageList1.GetImageIconUrl(ImgIndx)],
            //[UniNativeImageList1.GetImageBitmapUrl(ImgIndx)],
            Columns[ActionColIndx].ActionColumn.Buttons.Items[ActionItemIndx].JSMenuItem
    );
    JSInterface.JSCall('view.refresh', []);
  end;

end;

 

Link to comment
Share on other sites

1 hour ago, 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);
    }
}

 

Thank you ,Sherzod !

It's worked.

ActionColumnButtonsEnableDisable.png.5ec9deff5815d5537724b72e98b7eaf3.png

Link to comment
Share on other sites

2 hours ago, Sherzod said:

Can you try... ?


procedure TMainForm.UniButton1Click(Sender: TObject);
var
  ImgIndx,
  ActionColIndx,
  ActionItemIndx: Byte;
begin
  ImgIndx := 1;
  ActionColIndx := 6;
  ActionItemIndx := 0;

  with UniDBGrid1 do
  begin
    JSInterface.JSAssign(
            'icon',
            [UniNativeImageList1.GetImagePngUrl(ImgIndx)],
            //[UniNativeImageList1.GetImageIconUrl(ImgIndx)],
            //[UniNativeImageList1.GetImageBitmapUrl(ImgIndx)],
            Columns[ActionColIndx].ActionColumn.Buttons.Items[ActionItemIndx].JSMenuItem
    );
    JSInterface.JSCall('view.refresh', []);
  end;

end;

 

Sorry, I didn't  say it clearly.

My question should look like this image.

ActionColumnButtonsIconCls.png.e324fc90236f8e59be03007c72020845.png

Link to comment
Share on other sites

1 minute ago, Sherzod said:

Can you explain in more details?

One ActionColumn Button

When meet the condition 1 ,Button image or iconcls =A

When meet the condition 2,     Button image or iconcls =B

when meet the condition 3,     Button image or iconcls =C (Blank image or something).......

Link to comment
Share on other sites

14 minutes ago, zhyhero said:

One ActionColumn Button

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

 

Link to comment
Share on other sites

18 minutes ago, 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

 

Worked !

ActionColumnButtons.png.05b108d937e797e63772cc7203dbb237.png

Link to comment
Share on other sites

  • 2 months later...

Is it possible to change the hint according to the image?
for example:

     columns [actionColIndx] .items [actionItemsIndx] .getClass = function (value, metadata, record) {
         if (record.data [dataColIndx] == 100) {
             return "x-fa fa-check"
         }
         if (record.data [dataColIndx] == 101) {
             return "x-fa fa-times"
         }
         if (record.data [dataColIndx] == 102) {
             return "x-fa fa-stop-circle"
         }

== 100 Then Hint = 'Hint1'
== 101 Then Hint = 'Hint2'
== 102 Then Hint = 'Hint3'

Link to comment
Share on other sites

20 minutes ago, rtalmeida said:

Is it possible to change the hint according to the image?

 

On 2/13/2019 at 12:55 PM, Sherzod said:

And use this config for tips:


getTip: function(value, metadata, record, row, col, store) {
    //
}

 

Link to comment
Share on other sites

1 hour ago, rtalmeida said:

Unfortunately I did not understand this

OK

1. Leave the Hint property blank

HintActionColumn.png.9f1c6693aed9c28f3d1f90834d19788a.png

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

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{   
    //for example actioncolumnIndx = 6, actionButtonIndx = 0, recordDataIndx = 0
    columns[6].items[0].getTip = function(value, metadata, record, row, col, store) {
        return record.data[0] > 1500 ? 'Hint1' : 'Hint2';
    }
}

 

Link to comment
Share on other sites

  • 3 months later...

Normally Delphi Actions would dynamically change the visual things that link to them.

Are there any plans to make that the case for the actions that are linked to buttons in a dbgrid action column?

ie. Delphi developers that don't know how to use the client events won't need to know if the above is in place (much like a lot of what uniGui already does)

Link to comment
Share on other sites

  • 1 year later...
On 2/13/2019 at 2: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);
    }
}

 

Via code how do I make an icon invisible? In the form show, I check if the user is allowed to delete the record, if he doesn't, I would like to make the icon invisible, as well as the other icons as well.
The example you gave was based on a column value.

Link to comment
Share on other sites

28 minutes ago, Sherzod said:

?

Can I make the icon invisible? This via code, the form's onShow for example.

I have a column with 3 icons,
1 = Preview
2 = Change
3 = Delete

If my client is not allowed to delete I would like to make icon number 3 invisible, if he is not allowed to delete and change the record I have to disable icon number 2 and 3, you know?

Link to comment
Share on other sites

1 hour ago, eduardosuruagy said:

Can I make the icon invisible? This via code, the form's onShow for example.

I have a column with 3 icons,
1 = Preview
2 = Change
3 = Delete

If my client is not allowed to delete I would like to make icon number 3 invisible, if he is not allowed to delete and change the record I have to disable icon number 2 and 3, you know?

Try analize this code:

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

 

Link to comment
Share on other sites

13 minutes ago, Sherzod said:

Try analize this code:


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

 

I can't get it fixed on the grid

I need to do this via code:

if User.Exclude = False then
   False
else
true;

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