在Kendo模板中过滤源代码 [英] Filtering source in a Kendo Template

查看:124
本文介绍了在Kendo模板中过滤源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的Kendo模板和MVVM绑定。这个模板的源代码是viewModel,它里面有 employees 。员工集合有3条记录。我只需要显示那些 IsSelected 属性为真的记录。

 <!----剑道模板 - > 
< script id =row-templatetype =text / x-kendo-template>
< tr>
< td data-bind =text:name>< / td>
< td data-bind =text:age>< / td>
< / tr>
< / script>


员工:[
{名称:Lijo,年龄:28,IsSelected:true},
{名称:Binu,年龄: 33,IsSelected:false},
{name:Kiran,年龄:29,IsSelected:false}
]
$ b

QUESTION



我们如何在模板内指定这种过滤?



CODE

 < head> 
< title>模板过滤< / title>
< script src =http://code.jquery.com/jquery-1.9.1.min.js>< / script>
< script src =http://cdn.kendostatic.com/2013.2.716/js/kendo.all.min.js>< / script>
<!---- ---- Kendo模板 - >
< script id =row-templatetype =text / x-kendo-template>
< tr>
< td data-bind =text:name>< / td>
< td data-bind =text:age>< / td>
< / tr>
< / script>
<! - 使用Kendo绑定的MVVM接线 - >
< script type =text / javascript>
$ b $(document).ready(function(){
kendo.bind($(body),viewModel);
});

< / script>
< script type =text / javascript>
var viewModel = kendo.observable({

employees:[
{name:Lijo,age:28,IsSelected:true},
{ name:Binu,年龄:33,IsSelected:false},
{name:Kiran,年龄:29,IsSelected:true}
]
});

< / script>

< style>
table,th,td
{
border:1px solid black;
}
< / style>

< / head>
< body>
< table id =resultTable>
< tbody data-template =row-templatedata-bind =source:employees>
< / tbody>
< / table>
< / body>

REFERENCES


  1. KendoUI在网格中检查框:如何和一些提示和技巧
  2. //www.facebook.com/filter-kendo-ui-grid-with-filed-type-object\">使用提交的类型对象过滤kendo ui网格
  3. 过滤器数组|对象

  4. MVVM / Source和模板绑定

  5. 如何在模板中运行函数 使用可见的绑定。使用可见的绑定。 ..



    使用可见绑定



     < script id = row-templatetype =text / x-kendo-template> 
    < tr data-bind =visible:IsSelected>
    < td data-bind =text:name>< / td>
    < td data-bind =text:age>< / td>
    < / tr>
    < / script>


    I have following Kendo template and MVVM binding. Source for this is template is viewModel that has employees inside it. The employees collection has 3 records in it. I need to display only those records for which the IsSelected property is true.

    <!----Kendo Templates-->
    <script id="row-template" type="text/x-kendo-template">
          <tr>
                <td data-bind="text: name"></td>
                <td data-bind="text: age"></td>
          </tr>
    </script>
    
    
    employees: [
                        { name: "Lijo", age: "28", IsSelected: true },
                        { name: "Binu", age: "33", IsSelected: false },
                        { name: "Kiran", age: "29", IsSelected: false }
                       ]
    

    QUESTION

    How can we specify this filtering inside the template?

    CODE

    <head>
        <title>Template Filtering</title>
        <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script src="http://cdn.kendostatic.com/2013.2.716/js/kendo.all.min.js"></script>
        <!----Kendo Templates-->
        <script id="row-template" type="text/x-kendo-template">
              <tr>
                    <td data-bind="text: name"></td>
                    <td data-bind="text: age"></td>
              </tr>
        </script>
        <!--MVVM Wiring using Kendo Binding-->
        <script type="text/javascript">
    
            $(document).ready(function () {
                kendo.bind($("body"), viewModel);
            });
    
        </script>
        <script type="text/javascript">
            var viewModel = kendo.observable({
    
                employees: [
                            { name: "Lijo", age: "28", IsSelected: true },
                            { name: "Binu", age: "33", IsSelected: false },
                            { name: "Kiran", age: "29", IsSelected: true }
                           ]
            });
    
        </script>
    
        <style>
            table, th, td
            {
                border: 1px solid black;
            }
        </style>
    
    </head>
    <body>
        <table id="resultTable">
            <tbody data-template="row-template" data-bind="source: employees">
            </tbody>
        </table>
    </body>
    

    REFERENCES

    1. KendoUI Check Boxes in a Grid: how to and some tips and tricks
    2. Filter kendo ui grid with filed type object
    3. Filter Array|Object
    4. MVVM / Source and template binding
    5. how to run a function inside a template

    解决方案

    Use the visible binding...

    Use visible binding

    <script id="row-template" type="text/x-kendo-template">
        <tr data-bind="visible: IsSelected">
            <td data-bind="text: name"></td>
            <td data-bind="text: age"></td>
        </tr>
    </script>
    

    这篇关于在Kendo模板中过滤源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆