Jump to content


Photo

StringGrid Questions


  • Please log in to reply
27 replies to this topic

#21 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4148 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
  • 125 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
  • 125 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
  • 4148 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
  • 125 posts

Posted 07 February 2018 - 12:49 PM

Hi Delphi Developer,

 

  Build 1413.


  • 0

#26 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 125 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
  • 4148 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
  • 4148 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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users