Announcement

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

    No paging variables sent to ReST datasource

    I am using the latest version of SmartClient and Visual builder. (sC_SNAPSHOT-2011-01-06)

    I am in visual builder
    I have created ReST datasource using JSON
    I have created a listgrid
    Code:
    isc.DataSource.create({
        ID:"dataSource0",
        dataFormat:"json",
        dataURL:"http://keyapt:8888/rest-api/datasource/filterable-phone-numbers1.cfm",
        fields:{
            CONTACT_PHOTO_ID:{
                name:"CONTACT_PHOTO_ID",
                type:"string"
            }
        },
        recordXPath:"Response/data"
    })
    
    
    
    isc.ListGrid.create({
        ID:"ListGrid1",
        autoDraw:false,
        dataSource:"ref:dataSource0",
        autoFetchData:true
    })
    
    
    
    isc.DataView.create({
        ID:"DataView0",
        autoDraw:true,
        overflow:"hidden",
        members:[
            ListGrid1
        ],
        width:"100%",
        height:"100%"
    })
    I want to see paging. So I have my script return this response

    Code:
    {"Response":
        { "status":0
         ,"endRow":11
         ,"startRow":1
         ,"data":[
            {"CONTACT_PHOTO_ID":948}
            8 additional records removed for clarity.
            ,{"CONTACT_PHOTO_ID":933}
          ]
            ,
         "totalRows":151
         }
     }
    There are 11 records served to the grid but 151 in the dataset. I expect that when I scroll down it will make a request for more records.

    I observe grid never requests any more records.

    I expect that when the grid loads it will make a GET request with url parameters that have something to do with its default paging set up.

    I observe that a GET request is made but no parameters are provided.


    I have read the manual and tried every possible parameter during the last 6 hours before I simplifed to this scenario.

    * Please explain why I do not have any paging.

    #2
    RestDataSource has out-of-the-box support for paging in a very similar format to what you're returning (see the docs for that class).

    Just DataSource (the base class) does not assume any particular property names for startRow/endRow et al. You can extend DataSource to add support for your own paging properties (eg "startIndex" if you want to use that name) by implementing transformResponse, but not within Visual Builder (it's not for building custom classes).

    Comment


      #3
      RestDataSource works better than DataSource.

      I now have a get with the correct URL parameters but I still don't get any paging requests after the first load.

      Is the response from my server (given above correct). I read the manual entry and I think it is. So why won't it page?

      This is the new code

      Code:
      isc.RestDataSource.create({
          ID:"filterList",
          recordXPath:"Response/data",
          fields:{
              CONTACT_PHOTO_ID:{type:"string", title:"contact photo id", name:"CONTACT_PHOTO_ID"}
          },
          dataFormat:"json",
      	//sendMetaData:"true",
          dataURL:"http://keyapt:8888/rest-api/datasource/filterable-phone-numbers1.cfm"
      })
      
      
      isc.ListGrid.create({
          dataSource:filterList,
          ID:"ListGrid0",
      	width:600, height:100, alternateRecordStyles:true,
      	wrapCells: true,
          fixedRecordHeights: false,
          autoFetchData:true,
          autoDraw:false,
      	fetchmode:"paged",
      	dataPageSize: 10,
          drawAheadRatio:1,
      	fields: [
      		{	name:"CONTACT_PHOTO_ID",
      			title:"CONTACT_PHOTO_ID",
      			type: "string",
      		}
      
      	]
      })
      
      
      
      isc.VLayout.create({
          ID:"VLayout0",
          autoDraw:true,
          members:[
              ListGrid0
          ]
      
      })

      Comment


        #4
        Again, see the RestDataSource docs, there are sample responses, and yours does not match them in a few obvious ways (outer "Response" property, etc).

        Comment


          #5
          Thank you for your help. I corrected my mistake and have copied the manual entry.

          I now have new problem. The grid keeps making the same request continously but never renders the data. The request and my response are shown below.

          Code:
          http://keyapt:8888/rest-api/datasource/filterable-phone-numbers1.cfm?_operationType=fetch&_startRow=0&_endRow=75&_textMatchStyle=substring&_componentId=ListGrid0&_dataSource=filterList&isc_metaDataPrefix=_&isc_dataFormat=json
          Code:
          {
          	response:{
              	status:0,
                  startRow:0,
                  endRow:4,
                  totalRows:5,
               	data:[
                  	{"CONTACT_PHOTO_ID":948},
                      {"CONTACT_PHOTO_ID":938},
                      {"CONTACT_PHOTO_ID":933},
                      {"CONTACT_PHOTO_ID":960},
                      {"CONTACT_PHOTO_ID":961}
                  ]
               }
          }

          Comment


            #6
            PROBLEM SOLVED

            Code:
            isc.RestDataSource.create({
                ID:"filterList",
                recordXPath:"Response/data",
            In the definition of the RestDataSource the recordXPath was "Response/data".

            The correct value is "response/data".

            This caused endless requests because although the listgrid was being served data if could not unpack it.

            I found this solution by using the Smartclient console with ResultSet reporting set to "debug". Infact when you are really stuck setting the default reporting level to "debug" can be helpful.

            Comment

            Working...
            X