Announcement

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

    Criteria parameters automatically getting changed.

    I am using filter criteria to filter some data.
    But the criteria is getting transformed automatically to different format.

    ------
    //Code for my grid to filter
    Criteria filterEditorCriteria=getListGrid().getFilterEditorCriteria();
    filterEditorCriteria.addCriteria("planGiftStageTypeId.id",10001);
    filterData(filterEditorCriteria);
    ------

    ------
    //transform request method is overridden to view the actual value
    protected Object transformRequest(DSRequest dsRequest) {
    dsRequest.getCriteria().getValues(); // inspecting the values
    }
    ------

    In the actual criteria the attribute name was "planGiftStageTypeId.id" and value was "10001"

    But when i inspect and see it the DS, he attribute name is"planGiftStageTypeId" and value was "planGiftStageTypeId={id=null}"


    This is happening after migration from smartGwt3 to smartGwt6.
    Why is the data automatically getting converted to json format?
    How can I oass criterias that has a dot in it?





    #2
    You can't pass criteria that has a dot, because that's an invalid field name - see dataSourceField.name.

    This has always been the case - dots have never been allowed - but in older versions of SmartGWT the problems caused by invalid field names were less obvious.

    Comment


      #3
      The parameters that i am passing are not corresponding to any field. These are manually added to the filter criteria. These are parameters for a REST service, where the rest service provider expects the params in a format with dots.
      Is there any way to achieve this?

      Comment


        #4
        You can't declare the DataSource fields as having dots, but you can do whatever you want when sending the message. DataSource.transformRequest is your opportunity to take the DataSource data in eg a "fetch" request and change it before it's serialized. The specifics depend on how you implemented your code to contact the REST service, which you haven't talked about, but the docs for this start in the QuickStart Guide in the Data Integration chapter.

        Comment


          #5
          Yes, you are right. but my problem is different. I am not able to find out where the JSON transformation happens.

          My grid is having some code to filter data. There i am calling filterData( ) method.
          Then I am printing the dsRequest.getCriteria().getValues() to the console. (This is the first line in DataSource.transformRequest method, before executing the code to contact the rest service. )
          But here also the format automatically got changed. (That is the formatting is happening before DataSource.transformRequest gets executed)

          Is there any other place other than DataSource.transformRequest where we can write code to modify the request?

          Comment


            #6
            Using names containing a dot in that part of the system is invalid, as we covered before. That would explain the apparent conversion to JSON, which is not actually serialization, but just the consequences of using an invalid field name.

            If you think there's some kind of framework issue in your way here, get rid of all your invalid fieldNames and show a minimal, ready-to-run test case where you see criteria transformed in an unexpected way, and we can take a look.

            Comment

            Working...
            X