I build a filter select via ajaxProcessing function only if ajax returns filter_listbox object:
$.tablesorter.filter.buildSelect( "table", key, data.filter_listbox[value], true );
ajaxProcessing: function(data){
if (data && data.hasOwnProperty('rows')) {
var indx, r, row, c, d = data.rows,
total = data.total_rows, // total number of rows (required)
headers = data.headers, // array of header names (optional)
headerXref = headers.join(',').replace(/\s+/g,'').split(','), // cross-reference to match JSON key within data (no spaces)
rows = [], // all rows: array of arrays; each internal array has the table cell data for that row
len = d.length; // len should match pager set size (c.size)
// rows
for ( r=0; r < len; r++ ) {
row = []; // new row array
for ( c in d[r] ) { // cells
if (typeof(c) === "string") { // match the key with the header to get the proper column index
indx = $.inArray( c, headerXref );
if (indx >= 0) { // add each table cell data to row array
if (indx == 0) row[indx] = '<input type="checkbox" value="'+d[r][c]+'" />'; // input in first column
else row[indx] = d[r][c];
}
}
}
rows.push(row); // add new row array to rows array
}
// Select list on filter in column with index 3
if (typeof data.filter_listbox !== 'undefined'){
$.each(headers, function(key, value) {
//alert(value+" "+data.filter_listbox[value]);
$.tablesorter.filter.buildSelect( "table", key, data.filter_listbox[value], true );
});
}
// in version 2.10, you can optionally return $(rows) a set of table rows within a jQuery object
// return [ total, rows, headers ]; // Also change headers
return [ total, rows ];
}
},
Selectlist is built nicely, but if I choose an option from select, option is not selected in select list. Ajax returns data perfectlly, but if I click anywhere on the screen, table is updated like I would choose option with empty value and selectlist is broken. Can someone please help me to prevent this update and show properly selected option in the selectlist?