2012-02-05 4 views
0

スマートクライアントのLGPLバージョンを使用して自分のサーバーに接続したいと考えています。 SmartClientにフェッチ要求を送信したい(操作の種類、範囲などを含む)—残りを処理します。しかし、私はSmartClientにそれを強制することはできません。私がやったのは、簡単なGETリクエストを送ることだけでした。私は何を追加すべきですか?SmartClientでデータを取得するLGPLバージョン

マイコード:

<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> 

答えて

2

私は解決策を見つけました。ヒントは、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 
}); 

、その後、応答は次のようになります。

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

あなたがやりたい事は他の操作のためにあなたのURLを定義している:

は、個々のバインディングを持つDataSourceオブジェクトであなたのdataURLを置き換える:

operationBindings:[ 
{operationType:"fetch", dataURL:"<fetch URL>"}, 
{operationType:"add",dataProtocol:"postParams", dataURL:"<insert URL>"}, 
{operationType:"update",dataProtocol:"postParams", dataURL:"<Update URL>"}, 
{operationType:"remove",dataProtocol:"postParams", dataURL:"<delete URL>"}] 

IDグリッドを設定して編集可能にする:

ID:"MyGrid" 
canEdit: true, 
editEvent: "click" 

行を移動するときに更新要求が発生するはずです。

新しい行のためのボタンを追加し、次のコマンドを使用して行を削除:あなたが行から移動後

isc.IButton.create({title:"New",click:"MyGrid.startEditingNew()"}); 
isc.IButton.create({title:"Delete",click:"MyGrid.removeData()"}); 

あなたの追加URLはリクエストを受けるべきです。一度ボタンを押すと削除されます。

私はそれが役に立ちそうです。

関連する問題