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. 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. 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.