[英]How to make a row default selected in the jTable?
I got a jQuery jTable, in which I have a option to select a row form the table, but I want a row to be selected by default.我有一个 jQuery jTable,在其中我可以选择从表格中选择一行,但我希望默认选择一行。 How can I achieve this
我怎样才能做到这一点
$('#selectType').jtable({
selecting: true,
actions: {
listAction: //backend connection
},
fields: {
type:{
title:'Event Type',
list: true,
},
},
selectionChanged: function () {
var $selectedRows = $('#selectType').jtable('selectedRows');
if ($selectedRows.length > 0) {
$selectedRows.each(function () {
$type = $(this).data('record').type;
console.log("type=" + $type);
$('#Code').jtable(
'load',
{type: ($type)},
function () {
//some function to load all the values selected
}
);
});
}
},
});
$('#selectType').jtable('load')
In the above code, I want the selectType to have a row selected by default.在上面的代码中,我希望 selectType 默认选择一行。 I have tried this
我试过这个
$('#selectType').jtable('load', {code:"Call"})
but its not working.但它不工作。 Thanks.
谢谢。
I have added this function to select all the values in the table selected by default.我添加了这个函数来选择默认选择的表中的所有值。
function () {
$selectedRows = $('#Code').jtable('selectedRows');
$('#Code').jtable('selectRows', $selectedRows);
}
It worked after making few more adjustments with my original code.在对我的原始代码进行了更多调整后,它起作用了。
Thanks.谢谢。
According to JTable documents it is possible by adding rowInserted event:根据JTable 文档,可以通过添加 rowInserted 事件:
rowInserted: function (event, data) {
if (data.record.type == 'specificType') {
$('#StudentTableContainer').jtable('selectRows', data.row);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.