2017-09-22 91 views
0

我使用劍道網格,其中i有一個要求基於其將由另一function.I被返回的列的值,以產生動態HTML有以下代碼劍道網格根據列值在列中生成動態html?

$("#divGenerateLogin_kendogrid").kendoGrid({ 
 
       dataSource: { 
 
        data: data, 
 
        pageSize: 10 
 
       }, 
 
       sortable: true, 
 
       reorderable: true, 
 
       pageable: { 
 
        pageSizes: true, 
 
        buttonCount: 5 
 
       }, 
 
       filterable: true, 
 
       // selectable: true , 
 
       // dataBound: onDataBound, 
 
       columns: [ 
 
        { 
 
         field: "StudentName", 
 
         title: "Student Name", 
 
         type: "string" 
 
        }, 
 
        { 
 
         field: "Class", 
 
         title: "Class", 
 
         type: "string" 
 
        }, 
 
        { 
 
         title: "Login", 
 
         template: "#: LoginColHtml(IsLoginAvilable==1) #" 
 
        } 
 

 
       ] 
 
      }); 
 
      
 
      
 
      
 
function LoginColHtml(isLoginAvilable) { 
 

 
      var html = ""; 
 
      if (isLoginAvilable == true) { 
 
       html = "<button type='button' class='btn-ressetpwd'><i class='fa fa-key'></i> reset password</button>"; 
 
      } else { 
 
       html = "<button type='button' class='btn-generatelogin'><i class='fa fa-user'></i> generate login</button>"; 
 
      } 
 
      // "<div>#: (IsGuardianLoginAvilable==1) #</div>"; 
 
      return html; 
 

 
     }

而不是在列中返回實際的HTML,而是將其作爲字符串返回。我怎樣才能將實際的HTML添加到列而不是字符串?

FYI enter image description here

回答

0

我試圖與這和它的工作

{ 
 
    title: "Guardian Login", 
 
    template: "#= LoginColHtml(IsLoginAvilable==1) #"  
 
}