Jump to content


Photo

StringGrid Questions


  • Please log in to reply
45 replies to this topic

#21 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4789 posts

Posted 25 December 2017 - 05:22 PM

Hi,

 

One possible solution, try:

 

1. UniStringGrid1 -> ClientEvents -> UniEvents -> function beforeInit:

function beforeInit(sender, config)
{
    var me = sender;

    me.createStylesArray = function(rows) {
        var arr = [];
        for (var i = 0; i < rows; i++) {
            arr[i] = [];
        }
        return arr;
    };
}

2. UniStringGrid1 -> ClientEvents -> ExtEvents -> function reconfigure:

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    var me = sender;
    for (i = me.fxCols; i < columns.length; i++) {
        columns[i].renderer = function(value, meta, record) {
            if (me.rc && me.rc[meta.rowIndex][meta.columnIndex + me.fxCols]) {
                meta.style = me.rc[meta.rowIndex][meta.columnIndex + me.fxCols];
            }
            return value;
        }
    };
}

3. MainForm -> OnReady:

procedure TMainForm.UniFormReady(Sender: TObject);
begin
  UniStringGrid1.JSInterface.JSCode('var me='#1'; me.rc=me.createStylesArray(me.store.count());');
end;

How to use, for example:

procedure TMainForm.UniFormReady(Sender: TObject);
begin
  UniStringGrid1.JSInterface.JSCode('var me='#1'; me.rc=me.createStylesArray(me.store.count());');
  UniStringGrid1.JSInterface.JSCode(#1'.rc[2][2]="background-color:green; color:white";'#1'.view.refresh();');
end;
procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniStringGrid1.JSInterface.JSCode(#1'.rc[1][1]="background-color:green; color:white";'#1'.view.refresh();');
end;
procedure TMainForm.UniButton2Click(Sender: TObject);
begin
  UniStringGrid1.JSInterface.JSCode(#1'.rc[1][1]="";'#1'.view.refresh();');
end;

Best regards,


  • 0

#22 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 163 posts

Posted 30 January 2018 - 01:02 AM

Hi Delphi Developer,

 

  Is it possible to set up a column of cells (e.g. column 1) in a string grid so that when you click in a cell a TUniColorPalette is displayed underneath the cell, and once the user selects a

  color the cell background is set to this color?  I would also need to know what color was selected so I can store it in the cells object.

 

  The other question I have is how can I display a drop down combobox with some options in a cell and get the option that is selected so I can store it in a cell object?


  • 0

#23 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 163 posts

Posted 07 February 2018 - 01:50 AM

Hi Delphi Developer,

 

  Any help with the above two items would be appreciated.


  • 0

#24 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4789 posts

Posted 07 February 2018 - 10:49 AM

Hi,

 

Ok, I will try to analyze your requests,

 

Which build are you using?


  • 0

#25 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 163 posts

Posted 07 February 2018 - 12:49 PM

Hi Delphi Developer,

 

  Build 1413.


  • 0

#26 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 163 posts

Posted 13 February 2018 - 12:55 AM

Hi Delphi Developer,

 

  I noticed in this thread http://forums.unigui...d-color-combo/   you had created a color picker for DBGrid is it possible to implement this for a StringGrid rather than my idea above of using a TUniColorPalette?


  • 0

#27 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4789 posts

Posted 13 February 2018 - 03:03 AM

Hi,

I need to check it

Best regards,
  • 0

#28 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4789 posts

Posted 22 February 2018 - 06:45 AM

Hi,

 

Can you try this approach for now?:

 

1. Follow the steps as in this post: http://forums.unigui...id-color-combo/

 

2. UniDBGrid1 -> Columns -> "comboColor" column: Editor -> UniComboBox1

    function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) 
    {
        var me = sender;

        columns[1].renderer = function(v) {
            return '<span style="float: left; width: 33px; height: 15px; background: ' + getHexa(v) + '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;' + v;
        }
    }

    MainForm -> OnReady:

procedure TMainForm.UniFormReady(Sender: TObject);
begin
    UniStringGrid1.JSInterface.JSCall('columnManager.columns[1].setEditor', [UniComboBox1.JSControl])
end;

Result:

Attached File  stringGridEditor.png   9.47KB   0 downloads

 

Best regards,


  • 0

#29 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 163 posts

Posted 13 April 2018 - 04:32 AM

Hi Delphi Developer,

 

  I've noticed that if I use this code you provide:

UniStringGrid1.JSInterface.JSCode(#1'.rc[2][2]="background-color:green; color:white";'#1'.view.refresh();');

 Using the above as an example the cell[2,2] will have a background color of green but if you highlight this row and have row select  set to True, the row selection bar is not visible in cell[2,2] but is visible in cells that don't use the above code?


  • 0

#30 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4789 posts

Posted 13 April 2018 - 04:35 AM

Hello,

 

Can you please specify which build of UniGUI are you usong?!


  • 0

#31 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 163 posts

Posted 13 April 2018 - 04:37 AM

Build 1413.


  • 0

#32 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4789 posts

Posted 13 April 2018 - 04:41 AM

And please, can you capture an area of your app and save it directly to .GIF, for example by using LICEcap, so that we can see what's happening ?


  • 0

#33 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 163 posts

Posted 13 April 2018 - 04:45 AM

Hi Delphi Developer,

 

  Another question.

 

  I need to center an image in a stringgrid cell and based on what I have seen I need to set the following in the DIV:

style="text-align:center"

 I added the following to the CustomCSS in the ServerModule:

.supergrid .x-grid-cell-inner {
   text-align: center
}

What do I need to do to apply the above CSS to the DIV?


  • 0

#34 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4789 posts

Posted 13 April 2018 - 04:51 AM

Perhaps you should have to move to "ExtJS 6.5",

What do you think?!


  • 0

#35 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 163 posts

Posted 13 April 2018 - 05:01 AM

Hi Delphi Developer,

 

  Would moving to ExtJS 6.5 allow me to use the CSS above?

 

  Is there a reason why it can't be done in ExtJS 4?


  • 0

#36 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 163 posts

Posted 13 April 2018 - 05:03 AM

And please, can you capture an area of your app and save it directly to .GIF, for example by using LICEcap, so that we can see what's happening ?

 

In the attachment provided the row select bar is blue and the yellow first two columns are where the JS code was applied.

In this example you can see that the blue bar does not cover the yellow cells when the row is highlighted.

Attached Files


  • 0

#37 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4789 posts

Posted 13 April 2018 - 05:11 AM

Also you can try together with this approach:

http://forums.unigui...cus/#entry47751


  • 0

#38 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 163 posts

Posted 15 April 2018 - 12:11 PM

Hi Delphi Developer,

 

  Is there update on this as I need to be able to center an image in a cell?

 

 

Hi Delphi Developer,

 

  Another question.

 

  I need to center an image in a stringgrid cell and based on what I have seen I need to set the following in the DIV:

style="text-align:center"

 I added the following to the CustomCSS in the ServerModule:

.supergrid .x-grid-cell-inner {
   text-align: center
}

What do I need to do to apply the above CSS to the DIV?


  • 0

#39 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 163 posts

Posted 26 April 2018 - 10:18 AM

Hi Delphi Developer,

 

  Is it possible to remove the cell focus highlight so that no cell is highlighted in the stringgrid?

 

  is it possible to set the background color of the column titles row when ShowColumnTitles is True?

 

  Also is it possible to trap the click event on column title cells and then be able to call some other Delphi code?


  • 0

#40 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4789 posts

Posted 26 April 2018 - 10:27 AM

Hi,

 

Is it possible to remove the cell focus highlight so that no cell is highlighted in the stringgrid?

 

And it doesn't matter which cell is selected ?


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users