Announcement

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

    Dropdown type filters

    Hi,

    As we know that SmartGWT server side framework helps us filters data without any client side code.
    but the filter type is text , we write some text and data is filtered accordingly.

    If i have to filter the data in dropdown format i.e my filter should have some values in a dropdown and once a value is selected , it shows data respectively.

    One option is to write client side code for the same to fetch and create the value map for the same.

    Any other way to achieve the same?

    #2
    Hi marwan12,

    yes, like this:
    Code:
            <field name="abc" length="30" type="text" escapeHTML="true">
                <title><fmt:message key="idAfterUser" /></title>
                <valueMap>
                    <value>a</value>
                    <value>b</value>
                    <value>c</value>
                    <value>d</value>
                    <value>e</value>
                </valueMap>
            </field>
    or this:
    Code:
            <field name="DELIMITER" length="1" type="text" escapeHTML="true">
                <title><fmt:message key="delimiter" /></title>
                <valueMap>
                    <value ID=";"><fmt:message key="delimiterSemicolon" /></value>
                    <value ID=","><fmt:message key="delimiterComma" /></value>
                    <value ID="T"><fmt:message key="delimiterTab" /></value>
                </valueMap>
            </field>
    Best regards
    Blama

    Comment


      #3
      Hi Blama,

      In this we are populating the value map in ds.xml, what if i have to populate this on run time? example this is to be fetched based on some criteria and it is a field of some other ds.

      Comment


        #4
        Hi,

        use setFilterEditorProperties() on your ListGridField and set it to a SelectItem with setOptionDataSource().

        Best regards
        Blama

        Comment


          #5
          Thanks Blama , tried the same as

          DataSource hardwareTypeDS = DataSource.get(ClientConstants.HARDWARE_TYPE_DS);
          SelectItem selectItem = new SelectItem();
          selectItem.setDisplayField(TYPE_FIELD);
          selectItem.setValueField(TYPE_FIELD);
          selectItem.setOptionDataSource(hardwareTypeDS);
          selectItem.setMultiple(true);
          selectItem.setOptionOperationId("3");
          selectItem.setAutoFetchData(true);


          It is even displaying the values in the dropdown but while fitering it is appending BINARY '[value]' in the select clause giving no result
          The query formed is :
          SELECT COUNT(*) FROM image image, hdw_line WHERE
          (((hdw_line.HDW_TYPE_ID LIKE BINARY '[CL]' AND hdw_line.HDW_TYPE_ID IS NOT NULL)) AND (hdw_line.PRICE_BOOK_ID LIKE '%49481922%' AND hdw_line.PRICE_BOOK_ID IS NOT NULL) AND '1'='1') AND hdw_line.IMAGE_ID = image.image_id

          it is giving result with same query but no binary '[CL]' but only 'CL'

          Any idea to resolve the same?

          Comment


            #6
            Hi marwan,

            Try to create a testcase based on builtInDS for Isomorphic in order to look at it.
            You now know how to build a filter. The other issue is not related to ListGrid filtering, but sth. else. Is the datatype of the field correct in .ds.xml?

            Best regards
            Blama

            Comment


              #7
              Also one more difference i figured out that when i m not setting multiple="true" , it uses normal fetch query from ds.xml to get filtered data

              SELECT hdw_line.hdw_line_id, hdw_line.PRICE_BOOK_ID, hdw_line.PRODUCT_LINE, hdw_line.HDW_TYPE_ID, nullif(hdw_line.print_label,'') AS PRINT_LABEL, nullif(hdw_line.maintained,'') AS MAINTAINED, hdw_type.HDW_TYPE_ID AS PRODUCT_TYPE, image.description AS IMAGE_DESCRIPTION, image.show_image AS SHOW_IMAGE FROM hdw_type hdw_type, image image, hdw_line WHERE (((hdw_line.HDW_TYPE_ID LIKE BINARY 'CL' AND hdw_line.HDW_TYPE_ID IS NOT NULL)) AND (hdw_line.PRICE_BOOK_ID LIKE '%49481922%' AND hdw_line.PRICE_BOOK_ID IS NOT NULL) AND '1'='1') AND hdw_line.HDW_TYPE_ID = hdw_type.HDW_TYPE_ID AND hdw_line.IMAGE_ID = image.image_id LIMIT 0, 75

              but when i m using multiple="true", it uses another query:
              SELECT COUNT(*) FROM hdw_type hdw_type, image image, hdw_line WHERE (((hdw_line.HDW_TYPE_ID LIKE BINARY '[CL]' AND hdw_line.HDW_TYPE_ID IS NOT NULL)) AND (hdw_line.PRICE_BOOK_ID LIKE '%49481922%' AND hdw_line.PRICE_BOOK_ID IS NOT NULL) AND '1'='1') AND hdw_line.HDW_TYPE_ID = hdw_type.HDW_TYPE_ID AND hdw_line.IMAGE_ID = image.image_id

              Why it is using two different approaches for same grid fetch?

              Comment


                #8
                As I said, create a testcase or at the very least, tell your exact version number and the .ds.xml for the fields in question.

                Comment


                  #9
                  I got the issue finally , the setting of multiple="true" for multiselect filter uses multipleStorage which is not applicable for foreign keys
                  So it is working for simple fields but not for fields having foreign keys association


                  Thanks for your help, blama, really appreciate it .

                  Comment

                  Working...
                  X