1

NumericTextBox과 함께 검도 표를 사용하고 있습니다. 보통 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 필드는 두 개의 필드가있는 숫자 텍스트 상자입니다. 내 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

관련 문제