2013-01-31 93 views
1

確定一個特定的列,所以這裏的東西......我有3列格:房地順序,名稱和郵政編碼的onChange功能電網

第一列物業秩序是編輯(numericall)。我想要做的是:創建一個onChange函數來保存新插入的數字的值。我知道我需要一個程序,我只想知道如何捕捉值(在控制檯中),知道我擁有它並比我會執行該過程。

下面是代碼

PremisesGrid2 = $("#assignedRoute").kendoGrid({ 
       dataSource: { 
        type: "application/jsonp", 
        transport: { 
         read: 
           { 
            url: "http://" + servername + "/uBillingServices/Premise/Premise.svc/GetAllPremisesByRoute", 
            dataType: "json", 
            data: function() { 
             return { 

              Route_ID: selectedID, 
              UserName: userName, 
              WorkStation: workStation 

             } 
            } 
           } 
        }, pageSize: 10, 
        serverPaging: true, 
        schema: { 
         model: { 
          fields: { 
           ID: { type: "string", validation: { required: true },  editable: false }, 
           PostalCode: { type: "string", validation: { required: true }, editable: false }, 
           Latitude: { type: "string", validation: { required: true }, editable: false }, 
           Longitude: { type: "string", validation: { required: true }, editable: false }, 
           IsMember: { type: "string", validation: { required: true }, editable: false }, 
           Name: { type: "string", validation: { required: true }, editable: false }, 
           RouteOrderBy: { type: "number", validation: { required: true }, editable: true, nullable: false, format: "{0:n2}" } 
          } 
         }, 
         data: function (result) { 
          return result.rows || result; 
         }, 
         total: function (result) { 
          var data = this.data(result); 
          return result.totalRows || result.length || 0; ; 
         } 
        } 
       }, 
change: onChange, 
       dataBound: function (e) { 
        e.sender.select(e.sender.tbody.find(">tr:first")); 
       }, 
       selectable: "multiple", 
       scrollable: true, 
       filterable: true, 
       editable: true, 
       groupable: false, 
       pageable: { 
        numeric: true, 
        pageSizes: true, 
        previousNext: false 
       }, 
       sortable: { 
        mode: "single", 
        allowUnsort: false 
       }, 
       height: 400, 
       columns: [ 
       { field: "RouteOrderBy", title: "Premise Order", headerAttributes: { 
        style: "font-size:small; text-align:center" 
       }, attributes: { style: "text-align:right" } 
       }, 
        { field: "PostalCode", title: "Assigned Premises", headerAttributes: { 
         style: "font-size:small; text-align:center" 
        } 
        }, 
        { field: "Name", title: "Customer", headerAttributes: { 
         style: "font-size:small; text-align:center" 
        } 
        } 

        ] 
      }); 

謝謝。

回答

4

而不是使用change事件,您應該使用save。當不在值中的行的選擇發生變化時觸發change

爲了顯示編輯的值,含有該編輯的值,並在模型中的項的HTML元素,可以使用:

save : function (e) { 
    console.log("The values entered by the user.", e.values); 
    console.log("The jQuery element which is in edit mode.", e.container); 
    console.log("The edited model.", e.model); 
},