Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Fecth&UpdateData on ListGrid not executed

    Hello,

    I am using SmartClient/SmartGWT Framework v9.1p_2014-04-18/Pro Deployment.

    I created an array of two listgrids which are shown in tabs of a tabset and which are associated with the same datasource.
    If fetch is called on listgrid[0] it is not executed. The developer console does not show an RPC-call.
    If I change list[0].fetch to list[0].getDataSource.fetch the fetch is executed.
    Same holds for updateData

    Where's my mistake?

    Thank you
    Andreas

    #2
    Hi Andreas,

    you'll need to show some code.
    What comes in my mind:
    - Are the lg different Java objects?
    - Did you reuse ListGridFields in the lgs?

    Best regards,
    Blama

    Comment


      #3
      Hi,

      Here are some code fragments:
      1. ListGrid creation
      Code:
      examList = new ListGrid[2];
      examList[0] = createExamList ();
      examList[1] = createExamList ();
      ...
      private ListGrid createExamList () {
      	final ListGrid examList = new ListGrid () {
      		protected String getCellCSSText (final ListGridRecord record, final int rowNum, final int colNum) {
                      ...
      		}
      	};
      
      	examList.setSelectionType (SelectionStyle.MULTIPLE);
      	examList.setCanEdit (true);
      	examList.setEditByCell (false);
      	examList.setAutoSaveEdits (true);
      	examList.setAutoFetchData (false);
      	examList.setDataFetchMode (FetchMode.BASIC);
      	examList.setFilterLocalData (true);
      ...
      	return examList;
      }
      2. Assigning datasource to lg
      Code:
      public void setExamDS (final DataSource examDS, final Tree bldgTree) {
      	// List of field names to be shown
      	final List<String> lgFields = new ArrayList<String> ();
      	lgFields.add ("prfgGruppe");
      	lgFields.add ("stg");
      	lgFields.add ("titel");
      	lgFields.add ("prueferNamen");
      
      	ListGridField f;
      	final List<ListGridField> lfld = new ArrayList<ListGridField> ();
      	for (final ListGrid exlst : examList) {
      		exlst.setDataSource (examDS);
      		lfld.clear ();
      		// prepare list of fields not to be shown
      		for (final ListGridField lf : exlst.getFields ()) {
      			lf.setCanFilter (false);
      			if (lgFields.contains (lf.getName ())) {
      				lf.setCanEdit (false);
      			} else {
      				lfld.add (lf);
      			}
      		}
      		final ListGridField[] o = new ListGridField[lfld.size ()];
      		exlst.hideFields (lfld.toArray (o));
      
      		// configure fields
      		f = exlst.getField ("prfgArt");
      		f.setAlign (Alignment.CENTER);
      		f.setCanFilter (true);
      		f = exlst.getField ("prfgStatus");
      		f.setAlign (Alignment.CENTER);
      ...
      3. fetch
      Code:
      	final Integer id = Integer.valueOf ((String)planorgSelector.getValue ());
      	final Criteria crit = new Criteria ();
      	crit.addCriteria ("semid", AbstractWindowPresenter.getCurrentSemId ());
      	crit.addCriteria ("orgid", id);
      	crit.addCriteria ("inprfg", true);
      	examList[0].fetchData (crit, new DSCallback () {
      		@Override
      		public void execute (final DSResponse response, final Object data, final DSRequest dsRequest) {
      			examList[0].setData (response.getData ());
      			examList[0].ungroup ();
      			examList[0].unsort ();
      		}
      	});
      Since in other cases the same steps (creation, assigning, configuring, fetch) work I think that I forget something or I did something in wrong order.

      Bye
      Andreas

      Comment


        #4
        Hello,

        I reduced the code and found out the reason.

        I configured the ListGrid with 'setFilterLocalData (true)' in combination with 'setAllowFilterExpressions (true)' since I don't want to evaluate expressions like '..., OperatorId.GREATER_THAN, 10' on the server.
        But if the configuration 'setFilterLocalData (true)' is set first, a 'listgrid.fetchData()' is not performed.
        However, 'listgrid.getDatasource().fetchData()' works and the result passed to the listgrid by 'setData()' is filtered locally.

        Thank you
        Andreas

        Comment


          #5
          Hello,

          I have still difficulties with this setFilterLocalData-ListGrid.

          The editor of a cell is a PickTreeItem.
          In the changedHandler of the corresponding field the updateData-operation on the datasource is performed:
          Code:
          final Integer prfgpId = (examList[0].getSelectedRecord ()).getAttributeAsInt ("prfgGruppenId");
          final Record[] prfgrp =
          	examList[0].findAll (new AdvancedCriteria ("prfgGruppenId", OperatorId.EQUALS, prfgpId));
          for (final Record r : prfgrp) {
          	r.setAttribute ("roomId", event.getValue ().toString ());			
          	examList[0].getDataSource ().updateData (r, new DSCallback() {
          		public void execute (final DSResponse dsResponse, final Object data, final DSRequest dsRequest) {
          			examList[0].getDataSource ().updateCaches (dsResponse);
          		}
          	});
          }
          After these activities the cell shows the value of the ValueField instead of the value of the DisplayField.

          Any suggestions.
          Thank you
          Andreas

          Comment

          Working...
          X