Jump to content

Form / Toolbar / Grid: Click Toolbar Button - WRONG Grid Data Retieved - Please Advise ?


andyhill

Recommended Posts

grdMyData is Focused, User Navigates to a specivic Row, User Clicks Toolbar Button, Row Data Out Of Sync with Grid View ???

procedure TfMain.btnDeleteClick(Sender: TObject);
var
  DateStr: String;
begin
  try
    grdMyData.SetFocus;
    grdMyData.RefreshCurrentRow(True);
    DateStr:= DateToStr(grdMyData.DataSource.DataSet.FieldByName('GivenDate').AsDateTime); // RETRIEVES WRONG DATA ???
    MessageDlg(DateStr, mtConfirmation, [mbOK, mbYes], msgCongDeleteMyCallback);
    UniSession.AddJS('Ext.select("#messagebox-1001 .x-btn").elements[0].querySelectorAll(''[data-ref="btnInnerEl"]'')[0].innerHTML="Delete"');
    UniSession.AddJS('Ext.select("#messagebox-1001 .x-btn").elements[1].querySelectorAll(''[data-ref="btnInnerEl"]'')[0].innerHTML="Cancel"');
  except
  end;
end;

 

Link to comment
Share on other sites

grdMyData is Focused, 

User Navigates to a specific Row, 

User Clicks Toolbar Button -OR- User RightClicks Grid Cell (_CellXY_),

Row Data Out Of Sync with Grid View ???

 

          s:= 'cellmousedown=function cellmousedown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts) ' +
              '{ ' +
              '  var c = Ext.get(td).getXY(); ' +
              '  ajaxRequest(this, "_CellXY_", ["x="+c[0], "y="+c[1], "r="+rowIndex, "b="+e.button]); ' +
              '  sender.getEl().dom.addEventListener("contextmenu", function(e) ' +
              '  { ' +
              '    e.preventDefault(); ' +
              '  }) ' +
              '} ';
          grdMyData.ClientEvents.ExtEvents.Add(s);

  if EventName = '_CellXY_' then begin
    x:= StrToIntDef(Params.Values['x'], -1);
    y:= StrToIntDef(Params.Values['y'], -1);
    r:= StrToIntDef(Params.Values['r'], -1);
    b:= StrToIntDef(Params.Values['b'], -1);
    if ( (r > -1) and (b = 2) ) then begin
      try
        //DateStr:= DateToStr(UniMainModule.qryMyData.FieldByName('GivenDate').AsDateTime);
        DateStr:= DateToStr(grdMyData.DataSource.DataSet.FieldByName('GivenDate').AsDateTime);
        ShowMessage('Grid Row Number: '+IntToStr(r)+', GivenDate Fetch: '+DateStr);
      except
      end;
    end;
  end;

 

RightClick.jpg

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