Hello,
I'm trying to integrate the single search field in the datagrid referring the following post:
http://www.jeasyui.com/forum/index.php?topic=3420.0Changes have been done in the code referred from the thread. It works as expected.
However I'm facing one problem. Which is related to incorrect pagination options. Whenever I change the pageSize to some value greater than 10,
for example 50, and then enter my search criteria in the one search field, it filters and fetches the records, but the page size is set to 10 instead of being 50. I've tried the below code which works but filters and sets only the first 10 rows.
function doSearch(inp){
var rows = [];
var table_data = $('#dg').datagrid('getRows');
inp = inp.toUpperCase();
$.map(table_data, function(row){
for(var p in row)
{
var v = row[p];
var regExp = new RegExp(inp, 'i'); // i - makes the search case-insensitive.
if(regExp.test(String(v)))
{
rows.push(row);
break;
}
}
});
$('#dg').datagrid('loadData', rows);
}
When I use the below code, then the grid loads all the data instead of loading the data that had to be filtered. i.e the grid is loaded as if it was refreshed and
loads the initial data.
function doSearch(inp){
var rows = [];
var table_data = $('#dg').datagrid('getRows');
inp = inp.toUpperCase();
$.map(table_data, function(row){
for(var p in row)
{
var v = row[p];
var regExp = new RegExp(inp, 'i'); // i - makes the search case-insensitive.
if(regExp.test(String(v)))
{
rows.push(row);
break;
}
}
});
//$('#dg').datagrid('loadData', rows);
$('#dg').datagrid({
pageSize: $('#dg').datagrid('options').pageSize,
loadData: rows
});
}
Please could you tell me where I must be going wrong in setting the page size of the filtered criteria.
Also is it possible to create a single search field control and bind the doSearch() function with the input box as shown in the following link:
Thread link:
http://www.jeasyui.com/forum/index.php?topic=3342.0Fiddle link:
http://jsfiddle.net/gdXCX/Thanks & Regards,
Darrel