Jump to content
uniGUI Discussion Forums
bolossis

UniStringGrid Cell editor

Recommended Posts

Hi, is it possible to have an UniStringGrid  cell editor?

I try the hidden panel but this works only for UniDBGrid.

 

I have some Boolean values on a Stringgrid and want to have a checkbox inside the cells.

 

Any solution?

I check out the demos but found only solution for DBGrid.

 

 

Share this post


Link to post
Share on other sites

Yes one fixed Col and one Fixed Row.

 

If possible, can you make a testcase ?!

 

I'll work on your test case

Share this post


Link to post
Share on other sites

Hi Delphi Develeoper, you dont need a test case here,

its just a stringgrid with example 20 columns and 10 rows, one Fixed Cold and one Fixed Row and in the rest of the cells they should be a check box or a combobox where user can select false or true.

 

 test.jpg

0 = False

1 = True

 

Except of using zero and one, i would insert a check box or combobox (items=True,False)

Share this post


Link to post
Share on other sites

Hi,

 

Can you try to use this approach for now ?!

 

For example:

 

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

function beforeInit(sender, config)
{
    var me=sender;
    
    me._check=function(v, r, c){
        ajaxRequest(me, '_check', ['value='+v, 'rowIndex='+r, 'columnIndex='+(c+me.fxCols)]);
    }
}

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

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    for (i = sender.fxCols; i < columns.length; i++) {
        columns[i].rdonly=true;
        columns[i].align = 'center';
        columns[i].renderer = function(value, a) {
            return "<input type='checkbox'" + ((value == '1') ? "checked='checked'" : "") + " onclick='"+sender.nm+"._check(+this.checked, "+a.rowIndex+", "+a.columnIndex+")'>";
        };
    }
    
}

3. UniStringGrid1 -> OnAjaxEvent:

procedure TMainForm.UniStringGrid1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName='_check' then
    (Sender as TUniStringGrid).Cells[StrToInt(Params.Values['columnIndex']), StrToInt(Params.Values['rowIndex'])] := Params.Values['value']

end;

Result:

post-906-0-35543400-1514007260_thumb.png

 

Best regards,

  • Upvote 1

Share this post


Link to post
Share on other sites

Hello, is it possible to have an UniStringGrid  with combobox in cell?

Please i need help

Share this post


Link to post
Share on other sites

Hi,

 

Hello, is it possible to have an UniStringGrid  with combobox in cell?

Please i need help

 

Which edition and build are you using ?!

 

Best regards,

Share this post


Link to post
Share on other sites

Hi, i try to add and remove the events on runtime, is it possible?

If yes what do i wrong? it dows not work

procedure TRatesManagerForm.UniRadioButton9Click(Sender: TObject);
begin
  MyGrid.ClientEvents.ExtEvents.Clear;
  MyGrid.ClientEvents.UniEvents.Clear;

  RestGrid.ClientEvents.ExtEvents.Values['beforeInit'] :=
    'function (sender, config) ' +
    '{ ' +
    ' var me=sender; ' +
    '  me._check=function(v, r, c){ ' +
    '      ajaxRequest(me, ''_check'', [''value=''+v, ''rowIndex=''+r, ''columnIndex=''+(c+me.fxCols)]); ' +
    '    } ' +
    '} ';

  MyGrid.ClientEvents.UniEvents.Values['reconfigure'] :=
    'function (sender, store, columns, oldStore, oldColumns, eOpts) ' +
    '{ ' +
    '    for (i = sender.fxCols; i < columns.length; i++) { ' +
    '        columns[i].rdonly=true; ' +
    '        columns[i].align = ''center''; ' +
    '        columns[i].renderer = function(value, a) { ' +
    '            return "<input type=''checkbox''" + ((value == ''1'') ? "checked=''checked''" : "") + " onclick=''"+sender.nm+"._check(+this.checked, "+a.rowIndex+", "+a.columnIndex+")''>"; ' +
    '        }; ' +
    '    } ' +
    '} ';
end;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×