zhyhero Posted February 12, 2019 Share Posted February 12, 2019 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 ? 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 12, 2019 Share Posted February 12, 2019 Hi, Whether you prefer Disabled/Enabled instead of Hide/Show ? Quote Link to comment Share on other sites More sharing options...
zhyhero Posted February 12, 2019 Author Share Posted February 12, 2019 3 hours ago, Sherzod said: Hi, Whether you prefer Disabled/Enabled instead of Hide/Show ? Yes , of course . And another question ,can i change buttons imageindex or iconcls dynamically ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 12, 2019 Share Posted February 12, 2019 3 minutes ago, zhyhero said: Yes , of course OK, I will try to give you a solution a bit later Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 13, 2019 Share Posted February 13, 2019 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); } } Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 13, 2019 Share Posted February 13, 2019 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; Quote Link to comment Share on other sites More sharing options...
zhyhero Posted February 13, 2019 Author Share Posted February 13, 2019 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. Quote Link to comment Share on other sites More sharing options...
zhyhero Posted February 13, 2019 Author Share Posted February 13, 2019 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. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 13, 2019 Share Posted February 13, 2019 1 minute ago, zhyhero said: My question should look like this image. Can you explain in more details? Quote Link to comment Share on other sites More sharing options...
zhyhero Posted February 13, 2019 Author Share Posted February 13, 2019 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)....... Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 13, 2019 Share Posted February 13, 2019 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" } }; } Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 13, 2019 Share Posted February 13, 2019 And use this config for tips: getTip: function(value, metadata, record, row, col, store) { // } Quote Link to comment Share on other sites More sharing options...
zhyhero Posted February 13, 2019 Author Share Posted February 13, 2019 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" } }; } Worked ! Quote Link to comment Share on other sites More sharing options...
rtalmeida Posted April 21, 2019 Share Posted April 21, 2019 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' Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 21, 2019 Share Posted April 21, 2019 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) { // } Quote Link to comment Share on other sites More sharing options...
rtalmeida Posted April 21, 2019 Share Posted April 21, 2019 Unfortunately I did not understand this Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 21, 2019 Share Posted April 21, 2019 1 hour ago, rtalmeida said: Unfortunately I did not understand this OK 1. Leave the Hint property blank 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'; } } Quote Link to comment Share on other sites More sharing options...
rtalmeida Posted April 21, 2019 Share Posted April 21, 2019 Ok, Thank you Quote Link to comment Share on other sites More sharing options...
EOR Posted August 7, 2019 Share Posted August 7, 2019 Hi, Can I set Button size to 32x32 for examle? Thanx advise... Quote Link to comment Share on other sites More sharing options...
meason Posted August 8, 2019 Share Posted August 8, 2019 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) Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted October 30, 2020 Share Posted October 30, 2020 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. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 30, 2020 Share Posted October 30, 2020 2 hours ago, eduardosuruagy said: The example you gave was based on a column value. ? Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted October 30, 2020 Share Posted October 30, 2020 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? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 30, 2020 Share Posted October 30, 2020 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'; } }; } Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted October 30, 2020 Share Posted October 30, 2020 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; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.