2016-08-14 3 views
0

レコードがデータソースに挿入すると、以下のデータソース剣道UIグリッドのselectedRowでコマンドを実行する方法は?私は、コードを使用してい

dataSource.insert(0, data); 

の先頭に新しいレコードを挿入するために、私は編集コマンドを実行する必要があります。どうやってやるの?

私はシナリオは以下のようなものだと思う:

  1. が選択された行
  2. それは

ノートに編集コマンドを実行します、私は編集列を持っている必要はありません/ボタンをクリックします。

答えて

0

次のコードスニペットを試すことができます。

<div id="grid"> 
</div> 
<input type="button" value="set selected row in edit mode" onclick="setEditMode();" /> 
<script> 
    var dataSource = new kendo.data.DataSource({ 
     data: [ 
      { Name: "Lisa", Value: 1 }, 
      { Name: "Dan", Value: 12 }, 
      { Name: "Ken", Value: 5 }, 
      { Name: "Arthur", Value: 15 }, 
     ], 
     schema: { 
      model: { 
       fields: { 
        Name: { type: "string" }, 
        Value: { type: "number" } 
       } 
      } 
     } 
    }); 

    $("#grid").kendoGrid({ 
     dataSource: dataSource, 
     dataBound: function (e) { 
     }, 
     editable: "inline", 
     selectable: "single", 
     columns: [ 
      { field: "Name" }, 
      { field: "Value" } 
     ], 
     sortable: true 
    }); 
    //by using below code you can convert selected row into edit mode 
    function setEditMode() { 
     var grid = $('#grid').data('kendoGrid'); 
     grid.editRow(grid.select()); 
    } 
</script> 

ご懸念があれば教えてください。

関連する問題