smartclient

Fetch data with SmartClient LGPL version


I want to use LGPL version of smart client to connect to my own server. I want the SmartClient to send a fetch request (with operation type, range etc) — I'll handle the rest. But I can't force SmartClient to do it. All I managed to do is force it to send a simple GET request. What should I add?

My code:

    <HTML>
    <HEAD>
    <SCRIPT>var isomorphicDir="../isomorphic/";</SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_Core.js></SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_Foundation.js></SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_Containers.js></SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_Grids.js></SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_Forms.js></SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_DataBinding.js></SCRIPT>
    <SCRIPT SRC=../isomorphic/skins/SmartClient/load_skin.js></SCRIPT>
    </HEAD>
    <BODY>
    <SCRIPT>

    isc.DataSource.create({
        ID:"countries",
        dataURL:"countries_small.js",
        fields:[
            {name:"name", type:"text", primaryKey:true},
            {name:"population"},
        ]
    });

    isc.ListGrid.create({
        width: "100%",
        height: 50,

        dataSource: "countries",
        drawAllMaxCells:0,
        dataPageSize:1,
        drawAheadRatio:1,
        showAllRecords:false,
        autoFetchData: true
    });

    </SCRIPT>
    </BODY>
    </HTML>

Solution

  • ok, i found a solution. the clue is to use RestDataSource.

    isc.RestDataSource.create({
        ID:"countriesDS",
        dataFormat:"json",
        dataURL: "partial.js",
        operationBindings:[
                           {operationType:"fetch", dataProtocol:"postParams"}
                        ],
       fields:[
               {title:"Name", name:"name", type:"text", primaryKey:true},
               {title:"Population", name:"population", type:"text"}
           ]
    });
    
    isc.ListGrid.create({
        width: "100%",
        height: 60,
        dataFetchMode:"paged",
        dataSource: "countriesDS",
        dataPageSize:2,
        canEdit:true,
        drawAheadRatio:1,
        showAllRecords:false,    
        autoFetchData: true
    });
    

    and then, response may look like:

    { response:{
        status:0,
        startRow:0,
        endRow:1,
        totalRows:2,
        data:[
              {name:"Italy", population:"12"},
              {name:"Germany", population:"121"} 
        ]
      }
    }