Announcement

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

    ListGridRecord integer field gets string value

    I have a ListGrid that I am using in "detached" mode. I have setDataSource(myDataSource) and setSaveLocally(true). Then I'm doing using myDataSource.fetchData() followed by ListGrid.setData(DSResponse.getData()). All works fine and the ListGrid gets loaded with existing records.

    I then edit some of the existing records and add a new record to the ListGrid. When the user clicks a button I iterate over the list of records, select the ones I want to send to the server and append them as an attribute to the main record being submitted. Here is the list that gets sent to the server.
    Code:
            PoItemDetails:[
                {
                    IOVC:"RED-SCARLET",
                    IGTINTP:null,
                    ISBN:null,
                    ISKU:106369,
                    IQTY:88,
                    IGTIN:null,
                    ISIZ:2,
                    ICLR:1,
                    ISEQ:16,
                    _selection_102:true
                },
                {
                    IOVC:"YELLOW",
                    IGTINTP:"3",
                    ISBN:null,
                    ISKU:489,
                    IQTY:2,
                    IGTIN:"00000000000111",
                    ISIZ:2,
                    ICLR:2,
                    ISEQ:14,
                    _selection_102:false
                },
                {
                    IOVC:"GREEN",
                    IGTINTP:null,
                    ISBN:null,
                    ISKU:106351,
                    IQTY:3,
                    IGTIN:null,
                    ISIZ:1,
                    ICLR:3,
                    ISEQ:15,
                    _selection_102:false
                },
                {
                    IOVC:"BLUE",
                    IGTINTP:null,
                    ISBN:null,
                    ISKU:106377,
                    IQTY:4,
                    IGTIN:null,
                    ISIZ:2,
                    ICLR:4,
                    ISEQ:17,
                    _selection_102:false
                },
                {
                    ICLR:82,
                    ISIZ:1,
                    IQTY:"5"
                }
            ]
    The last record is the one that was added. As you can see, the field IQTY is a String "5" instead of just a number 5 like the other records. Why?

    This is the code I'm using to create the list to send to the server.

    Code:
    ArrayList<Record> detailRecs = new ArrayList<Record>();
    for (Record detailRec : myListGrid.getRecords()) {
     ... a complex if statement to decide whether to include the record, then
      detailRecs.add(detailRec);
    
    }

    #2
    This suggests that the record hasn't been through validation, which could be for various reasons, one of which would be not calling endEditing() or saveEdits() before grabbing the data to transmit to the server.

    However, if you declare this PoItemDetails field on it's parent DataSource such that it's "type" is the ID of another DataSource, it's going to be validated server-side anyway, so the value will be a true integer before it reaches DMI.

    Comment


      #3
      I've tried all of the various things you've suggested. On the client side I've tried calling endEditing() and saveAllEdits() before calling getRecords(). I even added setSaveByCell(true). It still sends the IQTY field to the server as a string.

      I also tried declaring the PoItemDetails field on the parent DataSource using a second data source PoItemDetail as it's type. The server still gets it as a String. On the server side I'm using a subclass of SQLDataSource and overriding the execute(DSRequest) method.

      Comment


        #4
        The effect of adding the DataSource on the server side should be that when the value is accessed from DMI logic or from your DataSource, it's a number at that point. Considering this change alone, it would still be expect to *arrive* at the server as a String (and would be shown in the server logs as a String).

        As far as not seeing the value as a number client-side, we'd need to see a test case for this - see if you can get it to happen by adding saveLocally:true to one of the editing samples. We don't seem to be reproducing it.

        Comment

        Working...
        X