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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...