Announcement

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

    ListGrid/ issue with filter

    When a user checks some records, then filters the data for searching for other records, and then removes the filter, the previously checked records are being unchecked.

    the 2 items selected before the filtering are not shown (as selected) in the ListGrid. So the user gets confused because he doesn't know that they are saved externally, so I would like to check them again for him. So that his view is consistent to what he already checked.

    I found the forum a way, I write "addDataArrivedHandler" but how could I do this? has anyone ever done this and could help me?

    Follow my code
    Code:
    private static ListGrid criaGradeAuxiliares() {
    		final ListGrid gridAuxiliares = new ListGrid();
    		gridAuxiliares.setDataSource(DataSource.get(Constantes.DS_USUARIO));
    		//gridAuxiliares.setAutoFetchData(true);
    		gridAuxiliares.setFetchOperation("usuariosFiscalizacao");
    		ListGridField colunaNome = FabricaComponentes.criaListGridField(new ConfigListGridField().setNome("nome"));
    		ListGridField colunaPerfil = FabricaComponentes.criaListGridField(new ConfigListGridField().setNome("perfil"));
    		ListGridField colunaUF = FabricaComponentes.criaListGridField(new ConfigListGridField().setNome("siglaEstado"));
    		ListGridField colunaEmpresa = FabricaComponentes.criaListGridField(new ConfigListGridField().setNome("empresaFiscalizadora"));
    		gridAuxiliares.setWidth100();
    		gridAuxiliares.setHeight(300);
    		gridAuxiliares.setFields(colunaNome, colunaPerfil, colunaUF, colunaEmpresa);
    		gridAuxiliares.setSelectionType(SelectionStyle.SIMPLE);
    		gridAuxiliares.setSelectionAppearance(SelectionAppearance.CHECKBOX);
    		gridAuxiliares.setShowFilterEditor(true);
    		gridAuxiliares.setFilterOnKeypress(true);
    		gridAuxiliares.setFetchDelay(ConstantesVisao.CAMPO_TAM_50);
    		gridAuxiliares.setAutoFetchData(true);
    	
    		return gridAuxiliares;
    	}
    thanks.

    #2
    Hi Rauel,
    Have you find solution for this issue?

    Currenlty im also facing the same but with TreeGrid :(

    Comment


      #3
      unfortunately, I still not found the solution, there is topic about this question.

      http://forums.smartclient.com/showthread.php?t=20259

      but the user didn't show the solution. :/
      Last edited by Rauel; 27 May 2013, 14:16.

      Comment


        #4
        I am not using this approach anymore (deleted the code a long time ago). That's why I can't just "post the solution code". But what is the problem with "You can write a addDataArrivedHandler to achieve this functionality. Since you already have the list of records selected by the user, you can check them when data arrives. The only disadvantage with this is your code iterates through the received records once for each data retrieval. I have successfully used this. Let me know if you have any concerns with this approach."

        So you add a RecordClickHandler for the listgrid, which for example adds the record to an external list every time the user selects a record: checkedRecords.add(selectedRecord). If the user deselects the record: checkedRecords.remove(selectedRecord).

        Then you add a dataArrivedHandler. In it you get the data that arrived with getData(). You iterate through it and compare the records with your "checkedRecords" list. If your record is in this list, you can select the record in the listGrid with listGrid.selectRecord(record).
        Last edited by edulid; 28 May 2013, 01:17.

        Comment


          #5
          A co-worker helped me and wrote this code to solve the problem

          Code:
          	private final class DataArrivedAuxiliaresHandler implements
          			DataArrivedHandler {
          		@Override
          		public void onDataArrived(DataArrivedEvent event) {
          			List<Map> value = (List) itemAuxiliares.getValue();
          			if(value == null) {
          				return;
          			}
          			ListGrid grade = (ListGrid)event.getSource();
          			//
          			
          			ListGridRecord[] records = grade.getRecords();
          			for (Map map : value) {
          			for (int i = 0; i < records.length; i++) {
          				ListGridRecord record = records[i];
          				if(map.get("id").equals(record.getAttributeAsInt("id"))) {
          					grade.selectRecord(i);
          					continue;
          				}
          			}
          }
          		}
          	}
          after i called the metod in my grid

          Code:
          this.gridAuxiliares.addDataArrivedHandler(new DataArrivedAuxiliaresHandler());
          Last edited by Rauel; 29 May 2013, 04:49. Reason: improve the code

          Comment


            #6
            It seems my problem is bit different :(
            1) Initially listgrid is unfiltered.
            2) User selected some records.(say 3records)
            3) User filtered data and got some records. Here he selected 2 more records.
            4) When he clears the filter, i'm able to see initially selected 3 records in selected state but newly selected records in unselected state.

            and similarly reverse case:
            1) when i filter data, i got initially selected records as a result.
            2) There i unselected a record and clearing the filter.
            3) Once i clear the filter, i'm getting all records with initial state ie., records with selected state before filter though i unselected a record.

            Donno how to solve these issues. Im still doing trial and errors.. :(
            Last edited by skaluva; 28 May 2013, 06:04.

            Comment

            Working...
            X