Jump to content

How do I validate a value from a stringgrid?


eduardosuruagy

Recommended Posts

1 hour ago, Sherzod said:

I will try to analyze and let you know

Maybe something like this as one of the possible solutions

1. UniStringGrid -> ClientEvents -> ExtEvents -> function edit(editor, context, eOpts):

function edit(editor, context, eOpts)
{
    var ctx=context;
    ajaxRequest(this, '_edit', 
        [
            'rowIdx='+ctx.rowIdx,
            'colIdx='+ctx.colIdx,
            'oldValue='+ctx.originalValue,
            'newValue='+ctx.value
            
        ]
    );
}

2. UniStringGrid -> OnAjaxEvent:

procedure TMainForm.UniStringGrid1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
var
  rowIdx, colIdx: Integer;
  oldValue, newValue: string;
begin
  if EventName = '_edit' then
  begin
    // some conditions
    if (Params.Values['rowIdx']<>'')and(Params.Values['colIdx']<>'') then
    begin
      rowIdx := StrToInt(Params.Values['rowIdx']);
      colIdx := StrToInt(Params.Values['colIdx']);
      oldValue := Params.Values['oldValue'];
      newValue := Params.Values['newValue'];
      //
      // some conditions
      // Params.Values['oldValue']
      // Params.Values['newValue']
      //
      (Sender as TUniStringGrid).Cells[colIdx, rowIdx] := '';
      (Sender as TUniStringGrid).Cells[colIdx, rowIdx] := oldValue;
    end;
  end;

end;

 

Link to comment
Share on other sites

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...