Announcement

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

    ListGridField.setMultiple(true) will not work.

    Using smartgwtpower2.5 nightly build, gwt 2.3.0. I've defined the valueMap in the .ds.xml file.
    Code:
     
    <field name="Blah" type="text">
     <valueMap>
      <value>A<value>
      <value>B<value>
      <value>C<value>
     </valueMap>
    </field>
    Then in the java code I create the listgrid and create a listgridfield for each field. For the field Blah I set multiple to true;

    Code:
     
    listGridField.setMultiple(true);
    I don't set the valueMap in the java code and I don't call fetchData(), I just have auto fetch to true. What do I need to do to get this to work?

    #2
    Can you explain what specific effect you are hoping for?

    Comment


      #3
      Originally posted by Isomorphic
      Can you explain what specific effect you are hoping for?
      Sure. I'd like to allow the user to select as many values from the list as he wants, i.e. A and B or A and B and C. Just like the multiple select example for the pickList on the showcase. Is this possible for a listGrid?

      Comment


        #4
        Originally posted by azuniga
        Sure. I'd like to allow the user to select as many values from the list as he wants, i.e. A and B or A and B and C. Just like the multiple select example for the pickList on the showcase. Is this possible for a listGrid?
        For each listgrid field that I wanted to include multiple select for, I had to create a SelectItem, setMultiple to true, and then add it to the listgridfield. This however doesn't play well with the query that is built from the filter. For example, if I select A & B from the multiple select item on the list grid, the sql query that gets executed is "select count(*) from table where column = '[A, B]' ". This always returns 0, since the query should instead read "select count(*) from table where column = 'A' OR column = 'B'. Any way to override this?
        Last edited by azuniga; 27 Sep 2011, 05:42.

        Comment


          #5
          Seems like there are a couple of things to mention here:
          1) For straight listGrid editing, you can mark the editor as "multiple", then when the user edits the field and submits the edited value for saving, the selected array of values will be saved out.
          This "multiple" setting can be applied directly to the editorProperties block, or to the underlying DataSourceField object. We agree it should also be supported on the ListGridField object and will make this change in the near future.

          2) It sounds like your use case is slightly different: you want the filter-editor for the field to be set as "multiple" and then for the generated criteria to match any of the selected values (via an "OR" type operation).
          This should be achievable by simply using 'setFilterEditorProperties' to specify the filter-editor item as being multiple:true.
          If this isn't working for you, or doesn't answer your use case, can you show us a simple test case we can run that demonstrates the problem? (Note that this should be a simple test case containing really just the DataSource, and ListGrid definitions -- you could use a simple clientOnly dataSource to eliminate the need for server code, or you could start with one of our simple shipped samples such as the built-in-ds example)

          Comment


            #6
            Originally posted by Isomorphic
            Seems like there are a couple of things to mention here:
            1) For straight listGrid editing, you can mark the editor as "multiple", then when the user edits the field and submits the edited value for saving, the selected array of values will be saved out.
            This "multiple" setting can be applied directly to the editorProperties block, or to the underlying DataSourceField object. We agree it should also be supported on the ListGridField object and will make this change in the near future.

            2) It sounds like your use case is slightly different: you want the filter-editor for the field to be set as "multiple" and then for the generated criteria to match any of the selected values (via an "OR" type operation).
            This should be achievable by simply using 'setFilterEditorProperties' to specify the filter-editor item as being multiple:true.
            If this isn't working for you, or doesn't answer your use case, can you show us a simple test case we can run that demonstrates the problem? (Note that this should be a simple test case containing really just the DataSource, and ListGrid definitions -- you could use a simple clientOnly dataSource to eliminate the need for server code, or you could start with one of our simple shipped samples such as the built-in-ds example)
            Option 2 sounds like what I need. Is this different from doing the following:
            Code:
            SelectItem sItem = new SelectItem();
            sItem.setMultiple(true);
            arrayOfListGridFields[counter].setFilterEditorProperties(sItem);
            I did this but like I said before, it didn't work since it wasn't seperated by an OR, instead it was like this, [A, B]. Is this what you meant or did you have something else in mind? All I want to provide is a dropdown with the values and allow the user to select multiple values, and for the query to be performed properly.

            Comment


              #7
              This should be all you need. You can try it out on any of the standard SQL (or clientOnly) dataSources we ship - for example adding a field like this:

              Code:
                      ListGridField unitsField = new ListGridField();
                      unitsField.setName("units");
                      SelectItem filterProps = new SelectItem();
                      filterProps.setMultiple(true);
                      
                      unitsField.setFilterEditorProperties(filterProps);
              To a grid bound to the standard SupplyItem dataSource visible in the built-in dataSource example behaves as you describe.
              In terms of the query - it is indeed sent down as a simple array of values on the field but this is interpreted as an "OR" type clause for fetch operations.

              Comment


                #8
                Originally posted by Isomorphic
                This should be all you need. You can try it out on any of the standard SQL (or clientOnly) dataSources we ship - for example adding a field like this:

                Code:
                        ListGridField unitsField = new ListGridField();
                        unitsField.setName("units");
                        SelectItem filterProps = new SelectItem();
                        filterProps.setMultiple(true);
                        
                        unitsField.setFilterEditorProperties(filterProps);
                To a grid bound to the standard SupplyItem dataSource visible in the built-in dataSource example behaves as you describe.
                In terms of the query - it is indeed sent down as a simple array of values on the field but this is interpreted as an "OR" type clause for fetch operations.
                This is exactly what I'm doing. In the log statement, however, I see that it is not interpreted as an OR clause. Here is what I get:
                Code:
                 
                === 2011-09-28 17:56:09,708 [l0-0] INFO  SQLDriver - [builtinApplication.Product_fetch] Executing SQL query on 'Oracle': SELECT COUNT(*) FROM TABLE, TABLE_TYPE WHERE 
                (((TABLE.Name = 'FOO' AND TABLE.Name IS NOT NULL) AND (TABLE_TYPE.TYPE = '[A, B]' AND TABLE_TYPE.TYPE IS NOT NULL) AND (TABLE_ATTRIBUTE_TYPE.NAME = '[A, B]' AND TABLE_ATTRIBUTE_TYPE.NAME IS NOT NULL) AND ('0'='1') AND (TABLE_THREE.NAME = '[A, B]' AND TABLE_THREE.NAME IS NOT NULL) AND '1'='1' AND '1'='1' AND '1'='1' AND '1'='1'))
                    	
                === 2011-09-28 17:56:09,720 [l0-0] INFO  DSResponse - [builtinApplication.Product_fetch] DSResponse: List with 0 items
                I also see that in the where clause there is a '0' = '1' there, where is that coming from?

                Comment


                  #9
                  Most likely, you have logic in a DMI, or client-side logic, that is running and is changing the value before it reaches the SQL layer.

                  Try the give sample code in the SDK *with nothing else* so that you can see that the behavior is correct before any of your customizations. Then, look at the value in the RPC tab, in the server side logs, and at other points in processing so you can see where you're changing it from an array to a String.

                  Comment

                  Working...
                  X