Tokay Posted March 12, 2022 Share Posted March 12, 2022 A DbGrid has action column with one button. It's necesserry to change image on the buttons depends of current dataset row data. The difficulty is that UniDBGrid1DrawColumnCell does not fired on such columns, if I understand correctly. Maybe this is a bug or it works by disign in such way? I'm use 1551 version. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 12, 2022 Share Posted March 12, 2022 2 hours ago, Tokay said: A DbGrid has action column with one button. It's necesserry to change image on the buttons depends of current dataset row data. The difficulty is that UniDBGrid1DrawColumnCell does not fired on such columns, if I understand correctly. Maybe this is a bug or it works by disign in such way? Hello, This post may help you: Quote Link to comment Share on other sites More sharing options...
Tokay Posted March 13, 2022 Author Share Posted March 13, 2022 Unfortunatelly I have no find any example how to change image depended on dataset. I additionally explain what is nedded to achive: row 1 has 0 value in the 2 column (with action buttons), then we show on grid button Image 0 from bineded TUniNativeImageList; row 2 has 4 value in the 2 column (with action buttons), then we show on grid button Image 4 from bineded TUniNativeImageList; row 3 has 2 value in the 2 column (with action buttons), then we show on grid button Image 2 from bineded TUniNativeImageList; and in that way all other rows. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 13, 2022 Share Posted March 13, 2022 57 minutes ago, Tokay said: Unfortunatelly I have no find any example how to change image depended on dataset. I did not say that there is a solution that meets your needs. Here you will find an alternative solution that may help you: Quote Link to comment Share on other sites More sharing options...
Tokay Posted March 13, 2022 Author Share Posted March 13, 2022 Ok, I see this post, but how to move from font (x-fa fa-home) to TUniNativeImageList images indexes? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 13, 2022 Share Posted March 13, 2022 8 minutes ago, Tokay said: but how to move from font (x-fa fa-home) to TUniNativeImageList Yes, I think you can describe above js event in OnCreate and refer to NativeImageList. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 13, 2022 Share Posted March 13, 2022 32 minutes ago, Tokay said: TUniNativeImageList images indexes Are you using font-awesome? Quote Link to comment Share on other sites More sharing options...
Tokay Posted March 13, 2022 Author Share Posted March 13, 2022 4 minutes ago, Sherzod said: Are you using font-awesome? No, I'm using own icons. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 13, 2022 Share Posted March 13, 2022 Just now, Tokay said: I'm using own icons. Can you share here? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 13, 2022 Share Posted March 13, 2022 4 minutes ago, Tokay said: I'm using own icons What is the type of icon? Quote Link to comment Share on other sites More sharing options...
Tokay Posted March 13, 2022 Author Share Posted March 13, 2022 1 minute ago, Sherzod said: What is the type of icon? Png images. Quote Link to comment Share on other sites More sharing options...
Tokay Posted March 13, 2022 Author Share Posted March 13, 2022 I need something like this (photoshopped example), 'Action' image index depends on, for example, CustomNo: Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 13, 2022 Share Posted March 13, 2022 10 minutes ago, Tokay said: I need something like this Yes, I understood. Need to analyze. 1 Quote Link to comment Share on other sites More sharing options...
Tokay Posted March 13, 2022 Author Share Posted March 13, 2022 Actually the data is in the 'Actions' column, not in the other. I.e. really need to show data (four states of the row/record) in the 'Actions' as buttons with different icons with action on they. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 13, 2022 Share Posted March 13, 2022 13 minutes ago, Tokay said: Actually the data is in the 'Actions' column, not in the other. I.e. really need to show data (four states of the row/record) in the 'Actions' as buttons with different icons with action on they. In that case, maybe you should use widget column? Quote Link to comment Share on other sites More sharing options...
picyka Posted March 13, 2022 Share Posted March 13, 2022 36 minutes ago, Tokay said: Na verdade, os dados estão na coluna 'Ações', não na outra. Ou seja, realmente precisa mostrar os dados (quatro estados da linha/registro) nas 'Ações' como botões com ícones diferentes com ação neles. Sorry for getting in here, in that case I couldn't use TField's GetText? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 14, 2022 Share Posted March 14, 2022 9 hours ago, Tokay said: Actually the data is in the 'Actions' column, not in the other. I.e. really need to show data (four states of the row/record) in the 'Actions' as buttons with different icons with action on they. 8 hours ago, Sherzod said: In that case, maybe you should use widget column? Using UniButtonWidget: procedure TMainForm.UniFormCreate(Sender: TObject); begin UniDBGrid1.ClientEvents.ExtEvents.Values['reconfigure'] := '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.setIcon("'+ UniMainModule.UniNativeImageList1.GetImagePngUrl(0) +'")'+ ' } else { '+ ' widget.setIcon("'+ UniMainModule.UniNativeImageList1.GetImagePngUrl(1) +'")'+ ' } '+ ' }; '+ '} ' end; Quote Link to comment Share on other sites More sharing options...
Tokay Posted March 14, 2022 Author Share Posted March 14, 2022 Thank you! I'll try Quote Link to comment Share on other sites More sharing options...
Tokay Posted March 14, 2022 Author Share Posted March 14, 2022 Quote var widgetColIndx=1; Another moment. How to find moved column? User can change column number during work. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 14, 2022 Share Posted March 14, 2022 4 minutes ago, Tokay said: Another moment. How to find moved column? User can change column number during work. Do you mean UniButtonWidget column? Do you have only one column with this widget? Quote Link to comment Share on other sites More sharing options...
Tokay Posted March 14, 2022 Author Share Posted March 14, 2022 9 minutes ago, Sherzod said: Do you mean UniButtonWidget column? Do you have only one column with this widget? yes for both questions Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 14, 2022 Share Posted March 14, 2022 2 minutes ago, Tokay said: yes for both questions procedure TMainForm.UniFormCreate(Sender: TObject); begin UniDBGrid1.ClientEvents.ExtEvents.Values['reconfigure'] := 'function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)'+ '{ '+ ' var widgetColIndx='+ UniDBGrid1.Columns[1].Index.ToString() +';'+ ' columns[widgetColIndx].onWidgetAttach = function(column, widget, record) {'+ ' if (record.get(widgetColIndx) == "Blue Angelfish") { '+ ' widget.setIcon("'+ UniMainModule.UniNativeImageList1.GetImagePngUrl(0) +'")'+ ' } else { '+ ' widget.setIcon("'+ UniMainModule.UniNativeImageList1.GetImagePngUrl(1) +'")'+ ' } '+ ' }; '+ '} ' end; ? Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 14, 2022 Share Posted March 14, 2022 41 minutes ago, Tokay said: Another moment. How to find moved column? User can change column number during work. Hi, I'm just drawing the NativeImagelist image from ActionButton Graphics when I create the query. Depending on a specific field in the table, I can put the necessary pictures. I do this on the server side. Quote Link to comment Share on other sites More sharing options...
Tokay Posted March 14, 2022 Author Share Posted March 14, 2022 6 minutes ago, irigsoft said: I can put the necessary pictures. Hi, is much better to share code 😀 Thank you! Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 14, 2022 Share Posted March 14, 2022 6 minutes ago, Tokay said: Hi, is much better to share code 😀 Thank you! 1. var myBMP : TMemmoryStream; TempBmp: TBitmap; TRY wei := TuniImage (MyClass).width; hei := TuniImage (MyClass).Height; myBMP := TMemoryStream.Create; TempBmp.SaveToStream(myBMP); myBMP.Position := 0; if (myBMP.Size > 0) AND (myBMP.Size <= TRUNC (20*1024*1024)) then begin TuniImage (MyClass).Picture.Bitmap.Canvas.Lock; TuniImage (MyClass).Picture.Bitmap.LoadFromStream(myBMP); TuniImage (MyClass).Picture.Bitmap.Canvas.UnLock; end; EXCEPT on E:Exception do begin END; myBMP.Size := 0; TempBmp.Free; myBMP.Free; 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.