Announcement

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

    QUESTION: DatasourceField, usage of "." in field name

    We have a grid displaying customizable data, recently someone started using the dots on column names and then reported that the grid does not correctly displays the data.

    Seems like that by default the grid expect nested data whenever it encounters a dot in a field name, and the same goes for updating data.

    For the field with name "field.name" I would expect the grid to send update as in (pseudo-code trying to explain myself)

    Code:
    ...
    data: { "field.name": "new value"}
    instead what the client sends to the server is

    Code:
    ...
    data: { "field" : { "name" : "new value" }}

    Is there a way to disable such behavior?

    #2
    Using a “.” in a field name is not valid.

    There is a supported server-side behavior for DataSourceField.valueXPath which is similar to what you have in mind.

    Comment


      #3
      I do not think xpath would solve my issue, let me include some of the actual data exchanged between client and server obtained with the SmartGWT Console.

      Issues:
      1. After the fetch "goodField" values is displayed correctly, but "dpm.displayOrder" is not.
      2. On the Update code the old values of the fields with dots are present among the updated values displayed as I tried to explain earlier


      Fetch:
      Code:
      {
          affectedRows:0, 
          data:[
              {
                  elementOrder:1, 
                  goodField:"sdasd", 
                  "dpm.displayOrder":1, 
                  "dpm.expansion.associatedGroup":"2", 
                  "dpm.expansion.editionName":"e"
              }
          ], 
          endRow:1, 
          invalidateCache:false, 
          isDSResponse:true, 
          operationType:"fetch", 
          queueStatus:0, 
          startRow:0, 
          status:0, 
          totalRows:1
      }

      Update:
      Code:
      {
          affectedRows:0, 
          data:{
              elementOrder:1, 
              goodField:"32", 
              dpm:{
                  displayOrder:22, 
                  expansion:{
                      associatedGroup:"23", 
                      editionName:"2"
                  }
              }, 
              "dpm.expansion.editionName":"e", 
              "dpm.displayOrder":1, 
              "dpm.expansion.associatedGroup":"2"
          }, 
          invalidateCache:false, 
          isDSResponse:true, 
          operationType:"update", 
          queueStatus:0, 
          status:0
      }

      Comment


        #4
        Since dots are not allowed in field names, you need to change the field names to not have dots.

        At that point, you could deliver the data as it currently is and transform it in DataSource.transformResponse(), but it’s not clear what the point of doing this would be; if you are working with some system where you are getting data with dots, the necessary transform may as well be server-side.

        Comment


          #5
          Originally posted by Isomorphic View Post
          Since dots are not allowed in field names, you need to change the field names to not have dots.
          Perfect, it's exactly what I needed to know.

          Comment

          Working...
          X