SmartGWT - Update ListGridRecord dynamically

Posted by Haylwood on Stack Overflow See other posts from Stack Overflow or by Haylwood
Published on 2010-04-20T12:29:45Z Indexed on 2010/04/20 12:33 UTC
Read the original article Hit count: 841

Filed under:
|
|

I am using SmartGWT and I have a ListGrid populated with an array of ListGridRecords using the setData() call. I am trying to update a progress property of a single record (on a timer for testing) and have it update in the browser. I have tried various combinations of draw(), redraw(), markForRedraw() etc. to no avail.

I also tried overriding the updateRecordComponent() method in my table class, but it only gets called when the records are first created (after createRecordComponent()).

I should note that I do NOT want to accomplish this by binding to a DataSource. I just want to be able to update the attribute on the client-side.

ArrayList<SegmentSortRecord> mRecords;
mRecords.add(new SegmentSortRecord("03312010_M001_S004"));
mRecords.add(new SegmentSortRecord("03312010_M001_S005"));
mRecords.add(new SegmentSortRecord("03312010_M001_S006"));
mRecords.add(new SegmentSortRecord("03312010_M001_S007"));

SegmentSortRecord[] records = new SegmentSortRecord[mRecords.size()];
mRecords.toArray(records);

mSortProgressTable.setData(records);

. . .

mTestTimer = new Timer()
{
   public void run()
   {
      mTestPercent += 5;

      if (mTestPercent <= 100)
      {
         mSortProgressTable.getRecord(2).setAttribute(Constants.PROGRESS_COL_NAME, mTestPercent);
         //mSortProgressTable.markForRedraw();
         //mSortProgressTable.redraw();
      }
      else
      {
         mTestPercent = 0;
      }
   }
};

...

@Override
protected Canvas createRecordComponent(final ListGridRecord aRecord, Integer aColumn)
{
   String fieldName = getFieldName(aColumn);      

   // Want to override the behavior for rendering the "progress" field
   if (fieldName.equals(Constants.PROGRESS_COL_NAME))
   {  
      Progressbar bar = new Progressbar();
      bar.setBreadth(10);
      bar.setLength(100);

      // The JavaScript record object contains attributes that we can
      // access via 'getAttribute' functions.
      bar.setPercentDone(aRecord.getAttributeAsInt(Constants.PROGRESS_COL_NAME));

      return bar;
   }

Thanks in advance for any help.

© Stack Overflow or respective owner

Related posts about smartgwt

Related posts about gwt