2014-11-17 2 views
0

интересно, может ли кто-нибудь помочь мне. У меня есть сетка Кендо, которая предположительно имеет по 2 ячейки на каждом конце каждой строки - эти две ячейки обновляются с вычисленным значением. Тем не менее, я заметил, что мои ячейки обновляются только в том случае, если у меня есть правка editable, как только я помещаю ее в false, значение не обновляется. Пожалуйста помоги!Kendo Grid Неизбираемые ячейки

var ds = new kendo.data.DataSource({ 
        transport: { 
         read: { 
          url: myurl, 
          dataType: "json" 
         } 
        }, 

        schema: { 
         model: { 
          fields: { 
           InvestmentCode: { type: "string", editable: false, }, 
           InvestmentName: { type: "string", editable: false, }, 
           Units: { type: "number", editable: false, }, 
           UnitPrice: { type: "number", editable: false, }, 
           MarketValue: { type: "number", editable: false, }, 
           AllocatedWithdraw: { type: "number", validation: { min: 0, max: 100 }, defaultValue: 0}, 
           IndicativeWithdraw: { type: "number", defaultValue: "0"}, 
           PostTransactionMarketValue: { type: "number", defaultValue: "0"} 
          } 
         } 
        }, 

        aggregate: [ 
         { field: "MarketValue", aggregate: "sum" }, 
         { field: "AllocatedWithdraw", aggregate: "sum" }, 
         { field: "IndicativeWithdraw", aggregate: "sum" }, 
         { field: "PostTransactionMarketValue", aggregate: "sum" } 
        ], 
       }); 

       $("#gridEditable").kendoGrid({ 
        dataSource: ds, 
        maxheight: 430, 
        sortable: false, 
        columns: [ 
         { 
          field: "InvestmentCode", 
          title: "Investment Code", 
          filterable: false, 

         }, 
         { 
          field: "InvestmentName", 
          title: "Investment Name", 
          format: "{0:MM/dd/yyyy}" 
         }, 
         { 
          field: "Units", 
          title: "Tradable Unit", 
          headerAttributes: { "class": "text-right-forced" }, 
          attributes: { "class": "text-right-forced" }, 
          format: "{0:#.##}", 
          template: "#= Units.toFixed(2) #", 
         }, 
         { 
          field: "UnitPrice", 
          title: "Unit Price", 
          headerAttributes: { "class": "text-right-forced" }, 
          attributes: { "class": "text-right-forced" }, 
          format: "{0:#.####}", 
          template: "#= UnitPrice.toFixed(4) #", 
         }, 
         { 
          field: "MarketValue", 
          title: "Current Market Value", 
          headerAttributes: { "class": "text-right-forced" }, 
          attributes: { "class": "text-right-forced" }, 
          format: "{0:c}", 
          footerTemplate: "#= kendo.toString(sum,'c') #", 
          footerAttributes: { "class": "text-right-forced" } 
         } 
         , 
         { 
          field: "AllocatedWithdraw", 
          title: "Allocated Withdraw", 
          width: "100px", 
          format: '{0:#.##} %', 
          headerAttributes: { "class": "text-right-forced" },       
          attributes: { "class": "text-right-forced" }, 
          footerTemplate: "#= kendo.toString(sum) #", 
          footerAttributes: { "class": "text-right-forced" } 
         } 
         , 
         { 
          field: "IndicativeWithdraw", 
          title: "Indicative Withdraw", 
          headerAttributes: { "class": "text-right-forced" }, 
          attributes: { "class": "text-right-forced" }, 
          format: "{0:c}", 
          footerTemplate: "#= kendo.toString(sum,'c') #", 
          footerAttributes: { "class": "text-right-forced" } 
         }, 
         { 
          field: "PostTransactionMarketValue", 
          title: "Post Transaction Market Value", 
          headerAttributes: { "class": "text-right-forced" }, 
          attributes: { "class": "text-right-forced" }, 
          format: "{0:c}", 
          footerTemplate: "#= kendo.toString(sum,'c') #", 
          footerAttributes: { "class": "text-right-forced" } 
         } 

        ], 
        editable: true, 
        save: function (data) {      

         var IndicativeWithdraw_Temp = ($("#iWithdraw").val()/100) * data.values.AllocatedWithdraw; 
         var PostTransactionMarketValue_Temp = data.model.MarketValue - IndicativeWithdraw_Temp; 

         data.model.set("AllocatedWithdraw", data.values.AllocatedWithdraw); 
         data.model.set("PostTransactionMarketValue", PostTransactionMarketValue_Temp); 
         data.model.set("IndicativeWithdraw", IndicativeWithdraw_Temp);       


         this.refresh(); 

        } 

       }); 

ответ

0

У меня была такая же проблема неделю назад. Кажется, пользовательский интерфейс kendo полагает, что не редактируемые поля не могут быть изменены, поэтому нет необходимости обновлять представление.

Я решил его вручную, установив новое значение в источнике данных, назначив ему оператор = (ПРИМЕЧАНИЕ: Set не обновляет поле в источнике данных) и обновляет ячейку сетки, добавляя к ней класс, чтобы я мог легко найти его.

function calculateScore(e){ 
    var row = e.container.closest("tr") 
    var item = $("#Grid").data("kendoGrid").dataItem(row); 
    item.A1A4 = item.A1 + item.A4; 
    row.find("td.smso_A1A4").text((item.A1 + item.A4).toString()); 
} 
Смежные вопросы