1

私はNumericTextBoxと剣道UIを編集可能なグリッドを使用しています。通常NumericTextBoxの場合、小数点は2つに制限されます。つまり、10.135を入力すると、値は10.14にフォーマットされます。しかし、私が必要とするのは10.135を得ることです。ここで何が行われるのですか?剣道UIモデルのdefenitionで数値の小数点以下の桁数を設定する方法は?

マイモデルの定義。

var GridViewModel = new kendo.data.Model.define({ 
    fields: { 
     Name: { type: "string", editable: false }, 
     Weight: { type: "number", editable: true, validation: { required: true } }, 
    } 
}); 

と私のビューモデルでは、グリッドを設定しました。

$("#DryingBinItemsAddedGrid").kendoGrid({ 
     dataSource: { 
      data: DataDetails, 
      schema: { 
       model: GridViewModel 
      }, 
     }, 
     editable: true, 
     dataBound: function() { 

     }, 
     columns: [ 
       { 
        field: "Name", 
        title: "Name" 
       }, 
       { 
        field: "Weight", 
        title: "Total Weight" 
       } 
     ] 
    }); 

この例では失敗した試行については言及していません。現在、私のWeightフィールドは、2つのフィールドを持つ数字のテキストボックスです。私のWeightフィールドに小数点以下3桁のNumericTextBoxを作るためにここで何をするか。

答えて

1

グリッドで使用されるNumericTextBoxの設定をエディタとして制御するには、カスタムエディタを実装する必要があります。それ以外の場合は、NumericTextBoxのデフォルト設定が使用されます(小数点以下2桁です)。

はにあなたの "重量" 列の定義を変更してみてください:

{ 
    field: "Weight", 
    title: "Total Weight", 
    editor: weightEditor 
} 

とカスタムエディタを実装weightEditor機能追加:

function weightEditor(container, options) { 
    $('<input name="' + options.field + '"/>') 
    .appendTo(container) 
    .kendoNumericTextBox({ 
     decimals: 3, 
    }) 
}; 

デモ:働いhttp://dojo.telerik.com/@Stephen/uviLO

+0

感謝を。 – Nitheesh

関連する問題