Menu

Refreshing Data

Help
don
2007-10-19
2013-04-03
  • don

    don - 2007-10-19

    Hey guys,

    I'm trying to (in code) refresh the datagrid.  I can't seem to figure out how to though.  I want to be able to do the same thing that happens when you click the 'refresh' button within my code.  Any help would be appreciated.

    Thanks,

    Don

     
    • don

      don - 2007-10-19

      I've solved this myself.. I exposed the CustomRBWindow dataGridWrapper to be accessible to client code and call, dataGridWrapper.loadData() when I want to refresh.

       
      • Skalyuk Andrij

        Skalyuk Andrij - 2007-10-20

        You have IAuthDataSource implementation in your RB.
        You can call GetData() and this will refresh RB

         
    • don

      don - 2007-10-22

      IAuthDataSource doesn't implement any method called GetData() that I can see?

       
    • don

      don - 2007-10-22

      IRowLoader contains the method GetData(), however this is for loading 1 row of data -- for use in an EditForm.

      What would be ideal, is having a reference to the currently active reference book, and being able to call refreshData() -- like the refresh button.

       
    • don

      don - 2007-10-22

      Exposing CustomRBWindow.dataGridWrapper, statically creating the dataGridWrapper wasn't a feasible solution because 1 instance of the dataGridWrapper must be created for each CustomRBWindow.

      However, that was exactly the solution I need.  Some way of referencing the loadData() method for the CustomRBWindow being displayed.  I just don't see any way of referencing the current CustomRBWindow instance.

       
      • Skalyuk Andrij

        Skalyuk Andrij - 2007-10-23

        Sorry for mistake.
        IAuthDataSource has:
        void select(SelectParams params, AsyncCallback callback);
        void selectCount(SelectParams params, AsyncCallback callback);

        if you call this methods you will refresh data in your reference book.

        Refresh grid component with wrapper in reference book:
        dataGridWrapper.loadData();

        Refresh low-level grid component:
        rbRows = (IDataRow[]) result;
        dataGrid.setDataSource(rbRows);
        dataGrid.dataBind();

        and you must implement IDataBinder interface for row binding.

         
    • don

      don - 2007-10-23

      I've pasted below a specific example of a method that I would like to refresh the datagrid, this returns the rows, however within this implementation I don't have access to the dataGridWrapper, nor am I sure where the 'rbRows' attribute is?
      When I call refreshData(), I'm not sure how to tell the datagrid to use this new resultset

      public class AttributeGroupRB implements IRB, IActionProviders {

          public static void refreshData()
          {
              AsyncCallback acallback = new AsyncCallback() {

                  public void onFailure(Throwable caught) {
                     
                  }

                  public void onSuccess(Object result) {
                      System.out.println(result);
                  }
              };
              instance.getDataSource().select(new SelectParams(), acallback);
          }

          private class AddFormProvider implements IAddFormProvider {
              public IAddForm getAddForm(IDataRow row) {
                  return new AddAttributeGroupForm();
              }

              public String getActionCaption() {
                  return null;
              }
          }

          private class EditFormProvider implements IEditFormProvider {
              public IEditForm getEditForm(IDataRow row) {
                  return new EditAttributeGroupForm(row);
              }

              public String getActionCaption() {
                  return null;
              }
          }

          private class SearchFormProvider implements ISearchFormProvider {
              public IParametersForm getSearchForm() {
                  return new SearchAttributeGroupForm();
              }

              public String getActionCaption() {
                  return null;
              }
          }

          private class ArchiveAttributeGroupCustomDialogProvider implements ICustomDialogProvider {
             
              public ICustomDialog getCustomDialog( IDataRow row ) {
                  ArchiveAttributeGroupCustomForm aa = new ArchiveAttributeGroupCustomForm( row );
                  return aa;
              }

              public String getActionCaption() {
                  return "Archive Attribute Group";
              }   
          }

          private class AttributeGroupRBDataSource implements IAuthDataSource {
              public void select(SelectParams params, AsyncCallback callback) {
                  AttributeGroupServiceAsync calService = AttributeGroupServiceLoader.getService();
                  calService.select(params, callback);
              }

              public void selectCount(SelectParams params, AsyncCallback callback) {
                  AttributeGroupServiceAsync calService = AttributeGroupServiceLoader.getService();
                  calService.selectCount((AttributeGroup) params.getSearchRow(), callback);
              }
          }

          public static ISelector getSelector(IDataColumn idColumn,
                  IDataColumn nameColumn) {
              return instance.new AttributeGroupSelector(idColumn, nameColumn);
          }

          private class AttributeGroupSelector implements ISelector {

              private IDataColumn idColumn;
              private IDataColumn nameColumn;

              public AttributeGroupSelector(IDataColumn idColumn, IDataColumn nameColumn) {
                  this.idColumn = idColumn;
                  this.nameColumn = nameColumn;
              }

              public void CopyRow(IDataRow sourceRow, IDataRow selectedRow) {
                  AttributeGroup row = (AttributeGroup) selectedRow;
                  sourceRow.setCell(idColumn, new DBInteger(row.getAttribute_group_id()));
                  sourceRow.setCell(nameColumn, new DBString(row.getName()));
              }

              public IRB getRB(IDataRow sourceRow) {
                  return new AttributeGroupRB();
              }

              public void setNull(IDataRow sourceRow) {
                  DataColumn.setNull(sourceRow, idColumn);
                  DataColumn.setNull(sourceRow, nameColumn);
              }

              public String getActionCaption() {
                  return null;
              }
          }

          private class AttributeGroupAddAttributeProvider implements IAddFormProvider {
              public IAddForm getAddForm(IDataRow row) {
                  AddAttributeForm aaf = new AddAttributeForm((AttributeGroup) row);
                  return aaf;
              }

              public String getActionCaption() {
                  return Locale.constants().add_attribute();
              }
          }
         
          private String caption = Locale.constants().attribute_group();

          private static IRBColumn[] rbColumns = new IRBColumn[]
          {
              new RBColumn(AttributeGroup.Columns.subcategory_name, 10),
              new RBColumn(AttributeGroup.Columns.attribute_group_id, 10),
              new RBColumn(AttributeGroup.Columns.name, 30),
              new RBColumn(AttributeGroup.Columns.description, 50),
          };

          public String getCaption() {
              return caption;
          }

          public IRBColumn[] getColumns() {
              return rbColumns;
          }

          public IAuthDataSource getDataSource() {       
              return new AttributeGroupRBDataSource();
          }

          public static AttributeGroupRB instance = new AttributeGroupRB();

          public IActionProvider[] getActionProviders() {
              return new IActionProvider[] {
                      new SearchFormProvider(),
                      new AddFormProvider(),
                      new EditFormProvider(),
                      new ArchiveAttributeGroupCustomDialogProvider(),
                      new AttributeGroupAddAttributeProvider(),
                  };
          }
      }

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.