【问题标题】:which is the last event in Kendo grid after databound这是数据绑定后剑道网格中的最后一个事件
【发布时间】:2016-05-03 12:29:34
【问题描述】:

我正在研究剑道网格,在其数据绑定事件中,我调用了一个函数来检查每个行的第二个块中的值是否大于第一个块。如果为真,那么我通过添加一个类来更改内部文本的颜色。 但是,问题是当我在浏览器上看到时,添加的类最终消失了。 如果有两行有错误,我正在编辑的第一行不包含该类,但后面的行保存得很好。

 dataBound: configureGridProperties,

dataBound 的代码是

    function configureGridProperties(e) {
    try {
        if (true) {
            $('#grid .k-grid-content tr[role=row]').each(function (i) {
                var sh = $(this).find('.sh').text();
                var sm = $(this).find('.sm').text()
                var eh = $(this).find('.eh').text()
                var em = $(this).find('.em').text()
                var startMin = parseInt(sh) * 60 + parseInt(sm);
                var endMin = parseInt(eh) * 60 + parseInt(em);
                if (startMin > endMin) {
                    showOutputExplicitly('Start time cannot be less than end time');
                    
                 
                  $(this).find('.sh, .sm,.eh,.em').addClass('timeError');
                    $('div.k-grid-pager').hide();
             
                    errorInTime = false;
                }
                else {
                       $(this).find('.sh, .sm,.eh,.em').removeClass('timeError');                      
                    if (!$('.timeError').length > 0) {
                        $('div.k-grid-pager').show();
                        hideErrorMsgSlow();
                        errorInTime = true;
                    }
                }
            });
        }          
        return false;
    } catch (e) {
    }

图片的情况。 >

我刚刚编辑的第二行(开始时间 23)不包含 colorChange 类,但较早的行包含该类。在dataBound事件之后是否还有其他事件发生?

【问题讨论】:

  • 试试这个dataBound: function() { setTimeout(configureGridProperties, 1); }
  • @DontVoteMeDown 是的,它神奇地起作用了......谢谢
  • 太棒了。将其发布为答案。

标签: javascript jquery kendo-ui kendo-grid jquery-events


【解决方案1】:

当调用 dataBound 时,网格 html 元素尚未使用新数据呈现。我知道这很奇怪,但除了使用setTimeout 来完成这项工作之外,我不知道其他方法。所以这可能有效:

dataBound: function(e) {
    window.setTimeout(configureGridProperties.bind(this, e), 1);
}

参考:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 2017-09-19
    • 2014-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多