2012-12-03 47 views
1

我正在加载Infragistics网格。加载时,我有一个模板列需要检查数据集中的另一个值,然后知道要加载的内容。它看起来不像Infragistics会让我这样做,所以我需要在网格加载后隐藏/显示特定信息时在网格上运行查询。Infragistics jQuery网格onLoad

例如:

我的网格:

  $("#divGrid").igGrid({ 
      columns: [ 
       { 
        headerText: "", 
        width: "70px", 
        key: "Division", 
        template: ProperRights.GetTemplate("${Division}") 
       } 
      ], 
      primaryKey: "EmployeeNumber", 
      autoGenerateColumns: false, 
      dataSource: AccountAdministrationGrid.GetGridData() 
     }); 

我的JS模板逻辑:

var ProperRights = new function() { 
    this.GetTemplate = function(division) { 
     if (division === 'DIV1') { 
      return 'Special Stuff'; 
     } else { 
      return "Boring Stuff"; 
     } 
    }; 
}; 

这就是我想做些什么,但ProperRights.GetTemplate刚刚返回$ {司}而不是网格行值。

所以我的下一个方法是在网格的末尾添加一个.ready()。然后遍历每个TD和一块来从该行的价值和手动更改我的值在第一列像这样:

.ready(function() { 
    $("td").each(function() { 
     var id = $(this).text(); 
     console.log(id); 
    }); 
}); 

但是,不能正常工作,它让回来为0 TD的找到类似网格尚未加载。

回答

6

在这种情况下,我建议使用Infragistics的模板引擎为您的列创建条件模板。

http://help.infragistics.com/Help/NetAdvantage/jQuery/2012.2/CLR4.0/html/Creating_Conditional_Template_Containing_Default%20Statement.html

http://www.infragistics.com/products/jquery/sample/templating-engine/conditional-row-template

在您的特定情况下,您可以尝试类似的东西:提供模板引擎,为igGrid特别是有条件的行模板的概述一些有用的资源,可以在下面找到:

 var ProperRightsTemplate = '{{if ${Division} == "Div1" }} <span> Some Value </span>'; 
     ProperRightsTemplate += '{{else}} <span> Some boring stuff </span> {{/if}}'; 

希望这会有所帮助。

+2

我如何在这里得到正确的答案,但Infragistics自己的支持门票上有错误的答案?谢谢。 – Boone