2016-01-18 89 views
1

我是kendo ui的新手。我需要你的幫助,請。我需要在某處使用複選框。我的問題是當我編輯任何記錄時,彈出菜單上的複選框可以顯示屬性的狀態,但網格不顯示。我想在網格的複選框中顯示記錄顯示的屬性。如何控制複選框並在網格上顯示kendo ui

我嘗試這個示例:http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Templates/grid-with-checkbox-column但它不適用於我的預期。

這裏是我的代碼:

    { 
         field: "isWorking", 
         title: "Çalışıyor", 
         editor: '<input type="checkbox" #= isWorking ? \'checked="checked"\' : "" # class="chkbx" />' 
        }, 
        { 
         command: [ 
          { 
           name: "edit", 
           text: { 
            edit: "", 
            update: "Tamam", 
            cancel: "İptal" 
           }, 
           className: "grid-command-iconfix" 
          }, 
          { 
           name: "destroy", 
           text: "", 
           className: "grid-command-iconfix" 
          } 
         ], 
         title: "&nbsp;", 
         width: "120px" 
        } 
       ], 
       editable: { 
        mode: "popup", 
        window: { 
         title: "Kayıt".i18n() 
        }, 
        confirmation: "Silmek istediğinizden emin misiniz?".i18n(), 
        confirmDelete: "Yes" 
       }, 
       edit: function (e) { 
        console.log(e); 
        $("#maritalStatus").data("kendoDropDownList"); 
       } 
      }); 
     } 
    }); 

    $("personGrid.k-grid-content").on("change","input.chkbx",function(e){ 
     var grid = $("#personGrid").data("kendoGrid"), 
      dataItem = grid.dataItem($(e.target).closest("tr")); 

     dataItem.set("isWorking", this.checked); 
    }); 

以及它是如何工作的截圖。請按照ss。 enter image description here

enter image description here

從這裏,這是從那裏被我放棄了問題臨客方案。

下面的代碼是我的第一份工作:

{ 
         field: "isWorking", 
         title: "Çalışıyor", 
         template: "<input type='checkbox' id='isWorking'/>" 
        }, 
        { 
         command: [ 
          { 
           name: "edit", 
           text: { 
            edit: "", 
            update: "Tamam", 
            cancel: "İptal" 
           }, 
           className: "grid-command-iconfix" 
          }, 
          { 
           name: "destroy", 
           text: "", 
           className: "grid-command-iconfix" 
          } 
         ], 
         title: "&nbsp;", 
         width: "120px" 
        } 
       ], 
       editable: { 
        mode: "popup", 
        window: { 
         title: "Kayıt".i18n() 
        }, 
        confirmation: "Silmek istediğinizden emin misiniz?".i18n(), 
        confirmDelete: "Yes" 
       }, 
       edit: function (e) { 
        console.log(e); 
        $("#maritalStatus").data("kendoDropDownList"); 
       } 
      }); 
     } 
    }); 

這裏是如何工作的SS。它在彈出編輯菜單上顯示狀態,但不顯示在網格上。 enter image description here

請你能幫幫我嗎?

回答

0

您正在設置模板中的複選框,但沒有設置其值。它將始終處於初始狀態。試試這個模板:

template: "<input type='checkbox' id='isWorking' # if (isWorking) { # checked=\"checked\" # } # />" 

Demo

+1

,我發現這個僅有2分鐘前模板:「<輸入名稱= 'isWorking' 類型= '複選框' 數據綁定= '檢查:isWorking' #= isWorking? checked ='checked':''#/>「它解決了我的問題,但它與您的建議一樣。謝謝你,我把你的答案變成綠色。 – luffy

相關問題