Jump to content

andyhill

uniGUI Subscriber
  • Posts

    1261
  • Joined

  • Last visited

  • Days Won

    6

Posts posted by andyhill

  1. Using Grid.Ext.Events 'validateedit'

    'validateedit' Event checks to see if the CurrCol is using a ComboBox editor, if so the Event processes the ComboBox's before and after values

    A Logic decision is made in code, if required then automatically populating other Grid Cells (on the same row) with new data relating to the new ComboBox value

    ComboBox Editing is closed <------- this is what your 'reconfigure' Event does now

    Grid moves on to next cell

    ALL THIS WORKS USING THE 'reconfigure' Event you gave me earlier.

    As A Teaching Lesson
    My additional question was why can't I just use the code below inside the Grid's 'validateedit' Event:- 

    UniSession.AddJS('Ext.defer(function(){'+GridJSName+'.editingPlugin.completeEdit()}, 10);');

    instead of relying on the ComboBox's 'reconfigure' Event to close the editor ?

    Is it a timing issue ?

  2. I have a need where the user can select from a grid's editor combobox an item of interest and then using the 'validateedit' event I fetch and populate the other specific row cell data relating to the selection = live update of SellPrice.

    The reason why it is not a DBComboBox is the fact that the user is also allowed to type in an item manually even if it does not exist in the combobox list.

    So if it exists, then SellPrice etc. is automatically updated in the grid, if not exist then user can type in the SellPrice manually.

    My code works to a point, but fails to advance to the next cell forcing a repaint, only by mouse clicking the next cell (or TAB Key) does the SellPrice display - our focus is stuck within the editors combobox no matter what we do in code - please advise.

    procedure TMainForm.grdWorkSheetAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
    
    ...
    
    col:= grdWorkSheet.CurrCol; // 1=Quantity, 2=Description, 3=SellPrice
    if col = 2 then begin
    
      UniMainModule.PreItemDescription:=  Trim(Params.Values['old']);
      UniMainModule.PostItemDescription:= Trim(Params.Values['new']);
    
      if ( (UpperCase(UniMainModule.PreItemDescription) <> UpperCase(UniMainModule.PostItemDescription))
      and  (UniMainModule.PostItemDescription <> '')
         ) then begin
    
        if UniMainModule.tblLkUpItems.Locate('Description', VarArrayOf([Trim(UniMainModule.PostItemDescription)]), [loCaseInsensitive]) = True then begin
          grdWorkSheet.Columns[2].Field.AsString:= UniMainModule.PostItemDescription;
          grdWorkSheet.Columns[3].Field.AsFloat:=  UniMainModule.tblLkUpItems.FieldByName('SellPrice').AsFloat;
          grdWorkSheet.Columns[4].Field.AsString:= UniMainModule.tblLkUpItems.FieldByName('BASType').AsString;
          grdWorkSheet.CurrCol:= grdWorkSheet.CurrCol + 1;
          grdWorkSheet.Repaint;
          ValidateBusyFlag:= False;
    ...

     

     

     

  3. Not quite what I am after.

    This is my JS code to read the Old Data and the Newly Typed Data OR the Newly Selected Combo Data.

      MyScript:= 'validateedit=function validateedit(editor, context, eOpts) '#10+
                 '{'#10+
                 '  n = context.value; '+
                 '  o = context.record.data[context.field]; '+
                 '  ajaxRequest(MainForm.grdWorkSheet, ''_ValidateEdit_'', ["new="+n, "old="+o]); '+
                 '} ';
      grdWorkSheet.ClientEvents.ExtEvents.Add(MyScript);

    In my grdWorkSheet _ValidateEdit_ event how can I replace the focused row's store data with the newly typed data and any other computed changes that I may have generated (a lot of logic has taken place inside the _ValidateEdit_ event, now I want the store's data to reflect my approved changes for that row).

     

  4. I need to send back via ajax the focused row, focused colX ([1] or by field name) the cell value - please advise how - thanks.

      MyScript:= 'validateedit=function validateedit(editor, context, eOpts) '#10+
                 '{'#10+
                 '  txt = this.columnManager.columns[1].getEditor().getValue(); '#10+
                 '  ajaxRequest(MainForm.grdWorkSheet, ''_ValidateEdit_'', ["t="+txt]); '+
                 '} ';
      grdWorkSheet.ClientEvents.ExtEvents.Add(MyScript);
     

     

×
×
  • Create New...