Slow To Update Grid When Programmatically Inserting Data

Hi Folks,

I am adding a column to a native grid, iterating through all rows and inserting data into the column. It takes an absolute age especially when rows exceed a few hundred. I have tried adding following lines but doesn’t seem to make a difference:

this.ultraGrid1.BeginUpdate();
this.ultraGrid1.SuspendRowSynchronization();

The column is discarded when the UI is closed it’s not written to the DB. Anyone have any tips to speed up this process?

I tried this a couple years ago and ran into the same thing. I think it was trying to get Part table info into a grid of JobMtl data in Job Tracker (or something similar). My code “worked” but was too slow to put into production.

I ended up scrapping the customization and using a BPM. The BPM ran on the GetByID method used in Job Tracker/Entry (forget the name). It queried the database with some LINQ code, and then wrote values to UD fields on ttJobMtl. The UD fields were already part of the JobMtl grid’s dataset, so no more need to add a column via customization. These UD fields were really just placeholders for this workaround; they served no purpose outside of the Job Tracker screen.

It felt like a bit of a hack at the time, but it worked and was fast. Would have preferred to keep everything in a customization, but I just wasn’t getting anywhere with that approach.

Thanks Tom, I explored BPM route but the grid is not directly linked to a table so not sure how to get access to a UD field. In the end I used an adapter to get the dataset a query to get additional data and a custom grid to display results. Not ideal but should be ok.

Yeah that is an incredibly slow way, are you doing a “lookup” for every row?

You need to use the ListObject perhaps for super fast speeds. @Chris_Conn is the master for that.

If I recall:

  myGrid.BeginUpdate(); 
  myGrid.SuspendRowSynchronization();
 
  foreach(var gRow in myGrid.Selected.Rows)
  {
      var lo = gRow.ListObject as DataRowView;
      if(lo == null) continue;
      lo["JobMtl_EnablePOSugg_c"] = !DeSelect;
      lo["RowMod"]= "U";
  }
 
  myGrid.ResumeRowSynchronization();
  myGrid.EndUpdate();

Anything special about that grid/date?
If not, maybe you can use the approach described in this thread?

Ended up re-purposing existing columns and passing data to those columns using a directive. This is the link that helped me…

1 Like