Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/11/20 in all areas

  1. Impressive contribution, sir! I will test your code as soon as possible,. In the meantime please accept my best regards! Augusto
    1 point
  2. Hello, I will give you the sequence of actions (one of the possible solutions of course, also you should think about error handling)... 1. UniDBGrid1.ClientEvents.ExtEvents -> function keydown(e, t, eOpts) { var grid = this.grid; grid.arr = []; grid.arrJSON = []; var models = this.grid.getStore().getRange(); if (e.ctrlKey && e.keyCode == 86) { navigator.clipboard.readText() .then(text => { grid.arr = text.split("\n"); if (grid.arr.length == 1) { grid.arr = text.split("\n"); } else { grid.arr.splice(-1, 1); } grid.arr.forEach(function(a, r) { a.split('\t').forEach(function(b, c) { console.log(b, r, c); try { grid.arrJSON.push({ "r": grid.uniRow + r, "c": grid.uniCol + c, "v": b }); //models[grid.uniRow + r].set(String(grid.uniCol + c), b) } catch (err) {} }) }); ajaxRequest(grid, 'copypaste', ['val='+JSON.stringify(grid.arrJSON)]); }) .catch(err => { console.error('Failed to read clipboard contents: ', err); }); } } 2. Uses ..., XSuperJSON, XSuperObject; https://github.com/onryldz/x-superobject 3. type TRec = record R: Integer; C: Integer; V: string; end; 4. UniDBGrid1.OnAjaxEvent procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var Test: TArray<TRec>; S: String; I: Integer; begin if EventName = 'copypaste' then begin S := Params.Values['val']; Test := TJSON.Parse<TArray<TRec>>(S); with (Sender as TUniDBGrid) do begin BeginUpdate; for I := 0 to High(Test) do begin DataSource.DataSet.RecNo := Test[I].R+1; DataSource.DataSet.Edit; DataSource.DataSet.Fields[Test[I].C].AsString := Test[I].V; DataSource.DataSet.Post; end; EndUpdate; end; end; end; Try...
    1 point
×
×
  • Create New...