PDA

View Full Version : Paging Grid / Table with filter?



TheBuzzer
29 Aug 2008, 8:35 AM
I realized in a paging grid and table it only filters the page it is showing and not query a new result using the filter,

just wondering is there a model of that set up or do that or not.

if not most likely have to make a new textbox that when inputted will query the store for a new type of filter or something. but not sure will that affect the sort orders too.

eugenparaschiv
8 Oct 2008, 7:05 AM
That would essentially be a server side filter. I need this as well. Any ideas out there? Thanks.

TheBuzzer
8 Oct 2008, 7:08 AM
well I just did some extra textfields to input filters along with the sort and stuff.

eugenparaschiv
8 Oct 2008, 7:17 AM
And how did that solve the problem of server-side filtering?
As I see it, if you have a large number of entries (thousands), you don't want to push them all into the client, so you display things with paging. But when you filter, you do want to filter the whole data set, not only the page being displayed. So you either filter on the server, or you push the whole thing on the client and filter there. But for a large number of entries, this is not practical. Besides, I read in an older post that server-side filtering will be available in 1.1, and now that 1.1 is out, I cannot seem to find it. Any ides on this? Thanks.

Cedric Lamalle
8 Oct 2008, 12:05 PM
To implement more easily this functionality the GXT API should be improved.
Let's explain the main difficulties:
1 - Extend the menu to add the filter item:
You can't extend the menu from a plugin (ComponentPlugin) because menu in GridView is a private member and GridView doesn't provide a getter from it.
Workaround: extend GridView and override createContextMenu, and set the GridView in the Grid after constuction.

2 - Passing the filters as parameters with the rest of the LoadConfig (SortInfo, offset, etc.)
There's no easy way to access the lastConfig associated with the Loader' Store.
WorkAround A: retrieve lastConfig via JSNI (tricky but works)
WorkAround B: subclass BasePagingLoader for instance and store the last config there.

Do anyone has another ideas?

TheBuzzer
8 Oct 2008, 12:34 PM
well the textbox for fitlering i submit it as more data where on server side i use that string as part of mysql string to do the filters.

TheBuzzer
8 Oct 2008, 12:37 PM
here is my getorders class header


public GetOrders(PagingLoadConfig config, Integer ordertype, String username, String filtertext, Date filterstartdate, Date filterenddate){




when i make a sql query



mytable.makeTable("SELECT * FROM `orders` WHERE " + wherefield + employeeid + filterstring + filterstartdatetext + filterenddatetext);




Oh ya I coded my own sql wrapper to get results quite easily by putting them into a vector of treemaps

Cedric Lamalle
8 Oct 2008, 12:54 PM
@TheBuzzer: I understand that it works, but it's not very extensible because you have to declare all your parameters in your service function.

@Me:
I've found a way to implement it as a plugin more easily:
1- Using HeaderContextMenu event of the Grid it's possible to add MenuItems on the headers' menu.
2 - Using BeforeLoad Event on ListStore or Loader I can't add the parameters in the LoadConfig.

TheBuzzer
8 Oct 2008, 4:26 PM
well do whatever works for u.

I was just giving a example on how i got server side filtering to work

silv
14 Jul 2009, 7:37 AM
Thought I'd add 2 cents here. A paging grid with server-side filtering would be excellent.

TheBuzzer
14 Jul 2009, 8:56 AM
gxt 2.0 lets you do server side filtering.


It can also hold extra variables in its model that it sends.

silv
14 Jul 2009, 9:01 AM
Really? That is fantastic. Do you know of any documentation on this?

TheBuzzer
14 Jul 2009, 9:06 AM
Just look at the gxt api.

There is no docs but just look at its code a little and you should be able to figure it out.

here is part of my grid code to give u a hint



private Listener<BaseEvent> changelistener = new Listener<BaseEvent>() {

@Override
public void handleEvent(BaseEvent be) {
if (be.getSource().equals(searchquery)) {
config.set("searchquery", searchquery.getValue());
loader.load();
} else if (be.getSource().equals(startorderdate)) {
if (startorderdate.validate()) {
config.set("orderfrom",startorderdate.getValue());
loader.load();
} else {
config.set("orderfrom",null);
}
} else if (be.getSource().equals(endorderdate)) {
if (endorderdate.validate()) {
config.set("orderto",endorderdate.getValue());
loader.load();
} else {
config.set("orderto",null);
}
}
}

};



see how you can set config to store extra stuff for filtering and stuff

stan229
14 Jul 2009, 9:44 AM
that's awesome!
I'm going to try that now.. what I was doing before was I created a filter object then i put the string representation of it into sortField and on the server side i synthesized the string to a filter object using groovy.. now i can just pass the object.. wicked

silv
14 Jul 2009, 9:45 AM
Thanks! I got it working. Much cleaner than the hacky stuff I was doing.

stan229
14 Jul 2009, 10:03 AM
Hm. I'm having an issue its not letting me put my object into it and send it to the server throws a serializationexception (yes i implemented serializable)


com.google.gwt.user.client.rpc.SerializationException: org.vnsny.abn.client.bean.WorklistFilter
org.vnsny.abn.client.ABNRecordService_TypeSerializer.raiseSerializationException(transient source for org.vnsny.abn.client.ABNRecordService_TypeSerializer:497), org.vnsny.abn.client.ABNRecordService_TypeSerializer.serialize(Native Method), com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter.serialize(ClientSerializationStreamWriter.java:216), com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129), com.extjs.gxt.ui.client.data.RpcMap_CustomFieldSerializer.serialize(RpcMap_CustomFieldSerializer.java:37), org.vnsny.abn.client.ABNRecordService_TypeSerializer.serialize(Native Method), com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter.serialize(ClientSerializationStreamWriter.java:216), com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129), com.extjs.gxt.ui.client.data.BaseModelData_FieldSerializer.serialize(transient source for com.extjs.gxt.ui.client.data.BaseModelData_FieldSerializer:16), com.extjs.gxt.ui.client.data.BaseListLoadConfig_FieldSerializer.serialize(transient source for com.extjs.gxt.ui.client.data.BaseListLoadConfig_FieldSerializer:25), com.extjs.gxt.ui.client.data.BasePagingLoadConfig_FieldSerializer.serialize(transient source for com.extjs.gxt.ui.client.data.BasePagingLoadConfig_FieldSerializer:15), org.vnsny.abn.client.ABNRecordService_TypeSerializer.serialize(Native Method), com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter.serialize(ClientSerializationStreamWriter.java:216), com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129), org.vnsny.abn.client.ABNRecordService_Proxy.getPagingRecords(transient source for org.vnsny.abn.client.ABNRecordService_Proxy:82), org.vnsny.abn.client.widgets.WorklistGrid$8.load(WorklistGrid.java:191), com.extjs.gxt.ui.client.data.RpcProxy.load(RpcProxy.java:21), com.extjs.gxt.ui.client.data.BaseLoader.loadData(BaseLoader.java:134), com.extjs.gxt.ui.client.data.BaseLoader.load(BaseLoader.java:98), org.vnsny.abn.client.forms.WorklistForm$3.componentSelected(WorklistForm.java:156), org.vnsny.abn.client.forms.WorklistForm$3.componentSelected(WorklistForm.java:1), com.extjs.gxt.ui.client.event.SelectionListener.handleEvent(SelectionListener.java:20), com.extjs.gxt.ui.client.event.SelectionListener.handleEvent(SelectionListener.java:1), com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:176), com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:96), com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:444), com.extjs.gxt.ui.client.widget.button.Button.onClick(Button.java:529), com.extjs.gxt.ui.client.widget.button.Button.onComponentEvent(Button.java:277), com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:760), com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1320), com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1299), com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1262)

TheBuzzer
14 Jul 2009, 10:13 AM
sorry, I don't know why it would be throwing errors if you have stuff serialized unless your using something that can't be serialized.

Even if a object is serializeable make sure the elements inside could be too

stan229
14 Jul 2009, 10:16 AM
Everything seems serilizable to me... I tried both Serializable and IsSerializable


package org.vnsny.abn.client.bean;

import java.io.Serializable;
import java.util.List;

import com.google.gwt.user.client.rpc.IsSerializable;

public class WorklistFilter implements IsSerializable {



/**
*
*/
private static final long serialVersionUID = -6093524570819817643L;

private String filterType;
private List<String> filterCriteria;

public WorklistFilter() {

}

public WorklistFilter(List<String> filterCriteria, String filterType) {
super();
this.filterCriteria = filterCriteria;
this.filterType = filterType;
}

public String getFilterType() {
return filterType;
}

public void setFilterType(String filterType) {
this.filterType = filterType;
}

public List<String> getFilterCriteria() {
return filterCriteria;
}

public void setFilterCriteria(List<String> filterCriteria) {
this.filterCriteria = filterCriteria;
}

@Override
public String toString() {
return filterType+":"+filterCriteria;
}

}

TheBuzzer
14 Jul 2009, 10:19 AM
it does look correct. no clue whats wrong with it for u :/

try getting rid of super() ?

stan229
14 Jul 2009, 10:39 AM
That didn't help. I guess its the RpcMap serializer.

TheBuzzer
15 Jul 2009, 1:46 PM
for serializable stuff i use

import java.io.Serializable;

public class FirstLoadData implements Serializable {

gtg489w
23 Jul 2009, 8:49 PM
I'm curious if anyone has done client side filtering with a multiple page grid? I can't seem to get the entire store to be filtered - I've only been able to get the current page in the grid to filter.

Any suggestions?

sirius.project
25 Jul 2009, 1:26 AM
you must use server side filter to do filter on multipage grid.

TheBuzzer
25 Jul 2009, 6:09 PM
you dont have to but you must load all the store data first.

gtg489w
25 Jul 2009, 9:02 PM
I have all the data in the store but I've been unsuccessful filtering across multiple pages in the grid... any suggestion in direction would be appreciated



@Override
public void handleEvent(BaseEvent be) {
if(!"".equals(searchText.getRawValue())) {
store.filter("name",searchText.getRawValue());
loader.load();
} else {
Dialog simple = new Dialog();
simple.setHeading("Search");
simple.setButtons(Dialog.OK);
simple.setBodyStyleName("pad-text");
simple.addText("You must enter text to search.");
simple.setHideOnButtonClick(true);
simple.show();
}
}