setTimeout(function(){
    //....
},0)    

方法会加入执行的栈中,简单的说就是异步操作

在渲染中,做最后一次数据转换的时候,可以大量使用

比如在easyui中,你可以这样,用以同步进行数据样式的转换

            $("#tb").datagrid({
                columns: [
                    [{
                        field: 'bookId',
                        title: '书名',
                        formatter: function(value, row, index) {
                            return $.conver("book",value);
                        }
                    }]
                ]
            })

也可以这样,异步进行数据的转换

            $("#tb").datagrid({
                columns: [
                    [{
                        field: 'bookName',
                        title: '书名',
                        formatter: function(value, row, index) {
                            setTimeout(function() {
                                $("#tb").datagrid('updateRow', {
                                    index: index,
                                    row: {
                                        "bookName": $.conver("book",value)
                                    }
                                },0)
                            })
                        }
                    }]
                ]
            })

 

posted on 2015-07-06 00:58  Glimis  阅读(253)  评论(0编辑  收藏  举报