Announcement

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

    ListGrid Filters from RpcDataSource

    Hi,
    I have problem using filters in listgrid bound to rpcDataSource. My listGrid (called CaseListGrid) displays list of cases. Each case is assigned to one user. I would like to filter the list of cases by assigned user (chosen from selectBox from filters bar). Hovewer, when I click on selectBox that should contain list of users the list is empty on contains only "Loading data..." text. Also, fetchData method from dataSource isn't called.

    Data is fetched from server via rpcDataSources - one for cases and one for users (based on code posted on this forum by Aleksandras Novikovas).

    Moreover, editing fields in list grid works without problem - after selecting row selectBox with user logins is displayed.

    I use smartgwt 2.2, gwt 2.0.3 and java 1.6.

    Here's my code:

    CaseListGrid:
    Code:
    public class CaseListGrid extends ListGrid {
    	
    	public CaseListGrid() {
    		setWidth100();
    		setHeight100();
    		setShowAllRecords(true);
    		setAutoFetchData(true);
    		setSelectionType(SelectionStyle.SINGLE);
    		setSelectionAppearance(SelectionAppearance.ROW_STYLE);
    		
    		List<ListGridField> fieldList = new ArrayList<ListGridField>();
    		
    		for(CaseField fieldType : CaseField.values()) {
    			ListGridField field = new ListGridField(fieldType.getName(), fieldType.getTitle());
    			field.setWidth(fieldType.getWidth());
    			
    			switch (fieldType) {
    				case CREATOR:
    				case CONSULTANT:
    					field.setDisplayField(UserField.LOGIN.getName());
    					field.setValueField(UserField.ID.getName());
    					field.setOptionDataSource(UserDataSource.getInstance());
    					
    					field.setCanFilter(true);
    					field.setEditorType(UserDataSource.getEditField());
    					field.setFilterEditorType(UserDataSource.getEditField());
    					break;
    					
    				default:
    					break;
    			};
    
    			fieldList.add(field);
    		}
    		
    		setFields((ListGridField[]) fieldList.toArray(new ListGridField[fieldList.size()]));
    		setDataSource(CaseDataSource.getInstance());
    		
    		setCanEdit(true);
    		setEditEvent(ListGridEditEvent.CLICK);
    		
    		setShowFilterEditor(true);
    	}
    Constructor for CaseDataSource. The part I commented out shows earlier approach that also didn't yield any results (when this code was used I didn't have the switch statement in CaseListGrid).
    Code:
    private CaseDataSource(String id) {
    		super(id);
    		
    		DataSourceIntegerField idField = new DataSourceIntegerField(ID.getName(), ID.getTitle());
    		idField.setPrimaryKey(true);
    		idField.setCanEdit(false);
    		
    		DataSourceDateTimeField createdField = new DataSourceDateTimeField(CREATED.getName(), CREATED.getTitle());
    		createdField.setCanEdit(false);
    		
    		DataSourceDateTimeField modifiedField = new DataSourceDateTimeField(MODIFIED.getName(), MODIFIED.getTitle());
    		modifiedField.setCanEdit(false);
    		
    		DataSourceDateTimeField deadlineField = new DataSourceDateTimeField(DEADLINE.getName(), DEADLINE.getTitle());
    		
    		DataSourceTextField creatorField = new DataSourceTextField(CREATOR.getName(), CREATOR.getTitle());
    //		creatorField.setTypeAsDataSource(UserDataSource.getInstance());
    //		creatorField.setForeignKey(UserDataSource.getInstance().getKeyField());
    //		creatorField.setEditorType(UserDataSource.getEditField());
    //		creatorField.setFilterEditorType(UserDataSource.getEditField());
    //		creatorField.setChildrenProperty(true);
    		
    		DataSourceTextField consultantField = new DataSourceTextField(CONSULTANT.getName(), CONSULTANT.getTitle());
    		
    		DataSourceTextField statusField = new DataSourceTextField(STATUS.getName(), STATUS.getTitle());
    		DataSourceTextField priorityField = new DataSourceTextField(PRIORITY.getName(), PRIORITY.getTitle());
    		
    		setFields(idField, createdField, modifiedField, deadlineField, creatorField, consultantField, statusField, priorityField);
    }
    Constructor for UserDataSource
    Code:
    private UserDataSource(String id) {
    		super(id);
    		
    		DataSourceIntegerField idField = new DataSourceIntegerField(ID.getName(), ID.getTitle());
    		idField.setPrimaryKey(true);
    		idField.setCanEdit(false);
    		
    		DataSourceTextField loginField = new DataSourceTextField(LOGIN.getName(), LOGIN.getTitle());
    		loginField.setCanEdit(false);
    		
    		DataSourceTextField nameField = new DataSourceTextField(NAME.getName(), NAME.getTitle());
    		nameField.setCanEdit(false);
    		
    		setFields(idField, loginField, nameField);
    }
    And finally method creating user SelectItem (also form UserDataSource)
    Code:
    public static final SelectItem getEditField() {
    		SelectItem userItem = new SelectItem();
    		userItem.setDisplayField(LOGIN.getName());
    		userItem.setValueField(ID.getName());
    		userItem.setOptionDataSource(UserDataSource.getInstance());
    		userItem.setAutoFetchData(true);
    		
    		return userItem;
    }
    Thanks in advance for any help! I've been stuck with this issue for some time now and could use any help.
    Last edited by Nexus42; 27 Jul 2010, 02:25.

    #2
    Try setting autoFetchData of selectItem to false, like this (maybe it will help):

    userItem.setAutoFetchData(false);

    Comment


      #3
      Hello

      I have the same issue (Combobox for filter is empty), so i ask you solve it.

      I appreciate your help, thanks

      Comment

      Working...
      X