Announcement

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

    JSON DataSource

    I am really struggling with deleting items from a grid, see my code below. Everything loads OK but when I click the 'Delete Selected' button the file that gets fetched (in firefox inspector) is not 'DeleteItem.php' as I would expect but DbaseConnection.php - although the correct parameters are sent. Can anyone suggest some pointers, why would the dataURL be fetched again when I've asked for removeData?


    isc.DataSource.create({
    ID: "DSToDo",
    fields:[
    {name:"TaskToDoID", title:"ID", width:50, type:"text"},
    {name:"TaskToDoDate", title:"Date"},
    {name:"TaskToDoJobNo", title:"Job No"},
    {name:"TaskToDoJobTitle", title:"Job Title"}
    ],
    dataFormat: "json",
    dataURL: "DbaseConnection.php",
    removeDataURL:"DeleteItem.php",
    addDataURL:"<notYetSet>",
    updateDataURL:"<notYetSet>"

    })

    isc.ListGrid.create({
    ID: "LGtoDo",
    width:900, height:300,
    dataSource: "DSToDo",
    autoFetchData: true,
    canEdit: true,
    canReorderFields: true
    })

    isc.IButton.create({
    left:340, top:340, title:"Delete Selected",
    click: function () {LGtoDo.removeData(LGtoDo.getSelectedRecord());
    }
    });

    #2
    did you try setting fetchDataURL instead of dataURL?
    The docs for dataURL says:

    Default URL to contact to fulfill all DSRequests.

    Comment


      #3
      Thanks a lot. Changing to fetchDataURL and isc.RestDataSource fetches the data but doesn't display it (shows 'No Items to Display') but at least pressing delete nows point to 'DeleteItem.php', so some progress.

      Comment


        #4
        oh, I didn't notice that you were using DataSource, not RestDataSource.
        With the latter, you have to return data using RestDataSource protocol: http://www.smartclient.com/#restEditSave

        Otherwise, have you seen this sample? http://www.smartclient.com/#xmlEditSave

        Comment


          #5
          Incase anyone else has trouble with this, my PHP script wasn't returning the correctly formatted data, I was missing the response, status & data part. As per the examples it must be in the format
          {
          response: {
          status: 0,
          data: [
          {
          taskID: "12"
          }
          ]
          }
          }

          Comment

          Working...
          X