Twitter bootstrap 将条纹添加到FuelUx中继器(数据网格)

Twitter bootstrap 将条纹添加到FuelUx中继器(数据网格),twitter-bootstrap,fuelux,Twitter Bootstrap,Fuelux,由于fuelux是bootstrap的一个扩展,我首先尝试通过将表作为标记来将“table striped”类添加到表中,并且还尝试获取表的类,即.table: $('table').addClass('table-striped'); 两者都不起作用,所以我尝试了fuelux使用的完整路径: $('.fuelux .repeater[data-viewtype="list"] .repeater-canvas .repeater-list table').addClass('table-st

由于fuelux是bootstrap的一个扩展,我首先尝试通过将表作为标记来将“table striped”类添加到表中,并且还尝试获取表的类,即.table:

$('table').addClass('table-striped');
两者都不起作用,所以我尝试了fuelux使用的完整路径:

$('.fuelux .repeater[data-viewtype="list"] .repeater-canvas .repeater-list table').addClass('table-striped');
不走运。它自己的表是由fuelux脚本动态创建的,所以我不确定如何引用它

通过查看文档,看起来list_columnRendered()函数可能会有所帮助,但我不确定该引用什么。我想我可以使用list_columnRendered(helpers.item)来定位表单元格(td),但我认为这会增加内联样式,如果可能的话,我希望避免这种情况


我最好将“table striped”类添加到table标记中。有没有办法针对js创建的标记?

我知道这是一个老问题,但如果你仍然在四处寻找答案,我会这么做。在中继器的初始化调用中,可以指定在中继器呈现其行时要运行的函数。上面提到了column rendered函数(list\u columnRendered)。如果希望像引导程序一样对表进行条带化,则需要挂接到list_rowRendered事件中

为此,请在中继器的初始化中添加以下行:

var repeaterReports = $("#reportList");    
repeaterReports.repeater({
            dataSource: getReportsData,
            list_noItemsHTML: "There are currently no reports to display.  If you performed a search you can clear the search using the x in the search box.",
            list_columnRendered: customColumnRendererReports,
            list_rowRendered: customRowRendererReports, // <--- you want this line.
            preserveDataSourceOptions: true
        });
这会奏效的

function dataSource (options, callback) { 
     /* add some data code here...*/   
     ...
     ...

     callback(dataSource);
     $('table').addClass('table-striped'); 
}

只需将其嵌套在函数datasouce中,并放在回调(dataSource)之后的末尾。这样就可以初始化表。

注意,您可能需要更改用于行高亮显示的颜色。我使用的颜色与引导使用的颜色相同,反过来,也是中继器用于高亮显示已排序行(应用排序时)的颜色。没什么大不了的,但你得小心点。
function dataSource (options, callback) { 
     /* add some data code here...*/   
     ...
     ...

     callback(dataSource);
     $('table').addClass('table-striped'); 
}