jsgrid中的子行 [英] Subrows in jsgrid

查看:131
本文介绍了jsgrid中的子行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 jsgrid 的帮助下创建具有一些行和列的表.单击一行后,它应该展开并显示一些SubRows.因此,我创建了row.click()函数.但是,当单击该行时,它将新内容附加在行的末尾,而不是我当前行的下面.这是一些代码示例

I try to create a table with some rows and columns with the help of jsgrid. On click on a row, it should expand and show some SubRows. I therefore created a row.click() function. But when clicking on the row it appends the new content at the end of the rows not under my current row.here is some code example

这是它的有效jsfiddle

rowRenderer: function(item) {
        var row = $("<tr>");

        var addressesGrid = $('<tr>').addClass('nested-grid').hide();
        addressesGrid.jsGrid({
            width: "100%",
            height: "auto",
            data: data,
            heading: false,
            fields: col
        })
        items= Object.keys(item)
       items.forEach(function(key){
           if(key!=items[items.length-1]) {
               var cell = $("<td>").addClass("jsgrid-cell").append(item[key])
               row.append(cell)
           }
        })
        row.click(function () {
            addressesGrid.toggle();
        })
        row.append(addressesGrid);


        return row
    }

推荐答案

而不是附加到第一行,您需要返回两行:

Instead of appending to the first row you need to return both rows:

return row.add(addressesGrid);

这是更正后的提琴 http://jsfiddle.net/9ftwLsmf/

这篇关于jsgrid中的子行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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