jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Field fiter "Grid"
Tagged: Custom Grid Filters
This topic contains 10 replies, has 3 voices, and was last updated by ekaperintis 12 years, 7 months ago.
-
AuthorField fiter "Grid" Posts
-
Hi all,
I’m have just started evaluating jqwidgets for a project and so far I’m loving it! however, I have just come stuck when trying to filter a grid from an input field. The filter seems to be grabbing the right data from the database, but I not sure how to refresh my grid using code below:
$(document).ready(function () {
var theme = ”;
var url = “{/literal}{$BASE_HREF}{literal}/test/users”;
var parentsLength = $(“#jqxWidget”).parents().length;
if (parentsLength > 3) {
url = ‘{/literal}{$BASE_HREF}{literal}/test/users’;
}// prepare the data
var source =
{
datatype: “json”,
datafields: [
{ name: ‘branchcode’ },
{ name: ‘branchname’ },
{ name: ‘fname’},
{ name: ‘sname’}
],
id: ‘id’,
url: url,
root: ‘data’
};//var dataAdapter = new $.jqx.dataAdapter(source);
var dataAdapter = new $.jqx.dataAdapter(source,
{formatData: function (data) {
data.name_startsWith = $(“#small-input”).val();
return data;
}
});$(“#jqxgrid”).jqxGrid(
{
width: 670,
source: dataAdapter,
theme: theme,
columnsresize: true,
columns: [
{ text: ‘Branch Code’, dataField: ‘branchcode’, width: 100 },
{ text: ‘Branch Name’, dataField: ‘branchname’, width: 340 },
{ text: ‘First Name’, dataField: ‘fname’, width: 100 },
{ text: ‘Surname’, dataField: ‘sname’, width: 100 }]
});var me = this;
$(“#small-input”).bind(‘keydown’, function (event) {
if ($(“#small-input”).val().length >= 2) {
if (me.timer) clearTimeout(me.timer);
me.timer = setTimeout(function () {
dataAdapter.dataBind();}, 300);
}
});});
The Grid’s ‘updatebounddata’ method refreshes the Grid’s data.
Best Wishes,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
That’s great thank you!… just one more thing
where on the code would i place it? i’ve tried and keep on getting a no object for jqgrid.
Rodrigo
Hi Rodrigo,
You can use the ‘updatebounddata’ method instead of dataAdapter.dataBind();
Best Wishes,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
I appreciate your help and don’t mean to be a pain, but I still can’t get the grid to reload the filtered data by doing the sample below. Unfortunately there aren’t any examples of such.
// FILTER
var me = this;
$(“#small-input”).bind(‘keydown’, function (event) {
if ($(“#small-input”).val().length >= 2) {if (me.timer) clearTimeout(me.timer);
me.timer = setTimeout(function () {//dataAdapter.dataBind();
$(‘#jqxgrid’).jqxGrid(‘updatebounddata’);}, 300);
}
});
I get the following error on my console:
Uncaught TypeError: Object # has no method ‘toArray’ jqxcore.js:7
a.jqx.invoke jqxcore.js:7
a.jqx.jqxWidgetProxy jqxcore.js:7
a.jqx.jqxWidget.a.fn.(anonymous function) jqxcore.js:7
o.extend.each jquery-1.3.2.min.js:12
o.fn.o.each jquery-1.3.2.min.js:12
a.jqx.jqxWidget.a.fn.(anonymous function) jqxcore.js:7
(anonymous function)I have also tried using the “filter api” and not having any luck either.
Essentially all i’d like to do is to have a “text/input” field with a “search/button” next to it. On click of button retrieve the data via json/php and refresh the grid.
Rodrigo
Do you use jQuery 1.7.2? We support versions of jQuery 1.6+. From your code, I think that you use jQuery 1.3.2 which is not supported.
Best Wishes,
Peter StoevjQWidgets Team
http://www.jqwidgets.comAH HA!!!! Thanks Peter, really appreciate your assistance/patience
downloaded 1.7.2 and looking better already!
Have a great one!
RodrigoAH HA!!!! Thanks Peter, really appreciate your assistance/patience
downloaded 1.7.2 and looking better already!
Can you to code programs that are run well ….
Thanks …
Hi ekaperintis,
We provide only UI tools. We currently do not offer other programming services.
Best Wishes,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter Stoev
I’m sorry, did not mean to offend you
I’m sorry if the language used is not understood, I’m from Indonesia and not too advanced english
thank you
-
AuthorPosts
You must be logged in to reply to this topic.