Jump to content

UniStringGrid Cell editor


bolossis

Recommended Posts

Part one was the checkbox filed inside UniStringgrid.

 

Now if you see in the image bellow i would like to activate - shows the checkbox fields only if radiobutton 3 or 4 are checked ( there are 4 chechboxes above the grid on the image, Min Stay, Max Stay, CTA, CTD)

 

test.jpg

Link to comment
Share on other sites

Can you try to use this approach for now ?!:

 

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)]);
    };

    me.isCheckbox=false; //<----------
}

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=me.isCheckbox; //<----------
        columns[i].align = 'center';
        columns[i].renderer = function(value, a) {
            return ((me.isCheckbox) ? "<input type='checkbox'" + ((value == '1') ? "checked='checked'" : "") + " onclick='"+sender.nm+"._check(+this.checked, "+a.rowIndex+", "+a.columnIndex+")'>" : value); //<----------
        };
    }    
}

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;

4. How to use, for example:

procedure TMainForm.UniCheckBox1Click(Sender: TObject);
begin
  with UniStringGrid1.JSInterface do
  begin
    JSAssign('isCheckbox', [UniCheckBox1.Checked]);
    JSCall('view.refresh', []);
  end;
end;

Best regards,

Link to comment
Share on other sites

 

Unfortunately i receive 

 

me is not defined

 

 

Oh, sorry:

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

    for (i = sender.fxCols; i < columns.length; i++) {
        columns[i].rdonly=me.isCheckbox; //<----------
        columns[i].align = 'center';
        columns[i].renderer = function(value, a) {
            return ((me.isCheckbox) ? "<input type='checkbox'" + ((value == '1') ? "checked='checked'" : "") + " onclick='"+sender.nm+"._check(+this.checked, "+a.rowIndex+", "+a.columnIndex+")'>" : value); //<----------
        };
    }    
}
Link to comment
Share on other sites

  • 1 month later...

An important question.

 

Can i do show checkboxes like in the example here only for specific rows?

 

Like show checkbox only for line(row) 1 or 2 etc?

 

 

This example here is great but when fixed Rows exists then it replace the fixed-rows value with a checkbox

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

    for (i = sender.fxCols; i < columns.length; i++) {
        columns[i].rdonly=me.isCheckbox; //<----------
        columns[i].align = 'center';
        columns[i].renderer = function(value, a) {
            return ((me.isCheckbox) ? "<input type='checkbox'" + ((value == '1') ? "checked='checked'" : "") + " onclick='"+sender.nm+"._check(+this.checked, "+a.rowIndex+", "+a.columnIndex+")'>" : value); //<----------
        };
    }    
}
Link to comment
Share on other sites

Hi,

 

You can try this:

me.isCheckbox && (a.rowIndex < 2) //<----------
function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) {
    var me = sender; //<----------

    for (i = sender.fxCols; i < columns.length; i++) {
        columns[i].rdonly = me.isCheckbox; //<----------
        columns[i].align = 'center';
        columns[i].renderer = function(value, a) {
            return ((me.isCheckbox && (a.rowIndex < 2)) ? "<input type='checkbox'" + ((value == '1') ? "checked='checked'" : "") + " onclick='" + sender.nm + "._check(+this.checked, " + a.rowIndex + ", " + a.columnIndex + ")'>" : value); //<----------
        };
    }
}

Best regards,

Link to comment
Share on other sites

  • 5 months later...

Hi Delphi Developer,

 

  I am trying to use the code on the first page to display a checkbox in a stringgrid but it doesn't seem to work.

 

  Is there some changes that need to be made to the original code so it works under Ext JS 6.5?

 

 I am using Complete Professional 1466.

Link to comment
Share on other sites

  • 3 weeks later...

Hi Delphi Developer,

 

  The code you posted on the first page of this thread on the 23rd Dec 2017.

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

etc...

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...
  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...