Following the example at http://www.wobblycogs.co.uk/index.php/computing/jee/49-dynamic-dashboard-with-primefaces im trying to create a dynamic dashboard.
Copying the code works 100% perfeclty, but im trying to use it with my own implementation.
When i load my index page it dosnt show any panels or the dashboard at all. When i navigate to a differet page, and come back the elements appear!
I have no idea why the dashboard is not displayed on initial page load.
Im working with Jboss 5.1, EJB 3.0, JSF 2.0 and Primefaces 3.4.
This is the top of my controller class:
#Model
#ViewController(viewId = "/pages/index.xhtml")
public class MonitorController implements Serializable, ViewInitializer, ViewFinalizer {
#Inject
private transient MonitorService monitorService;
#Inject
private transient MonitorUserService monitorUserService;
#Inject
private transient MonitorView view;
#Inject
private transient Conversation conversation;
#Override
public void initializeView() {
if (conversation.isTransient()) {
conversation.setTimeout(1800000);
conversation.begin();
}
MonitorUser user = monitorUserService.findOrCreateUser();
view.setUser(user);
List<MonitorElement> elements = monitorService.findMonitorElementsByUser();
view.setElements(elements);
view.setUsersMonitorElements(elements);
createDashBoard();
}
This is my method for creating the dashboard, adding panels and setting the column widgets:
public void createDashBoard() {
final int DEFAULT_COLUMN_COUNT = 3;
int columnCount = DEFAULT_COLUMN_COUNT;
Dashboard dashboard;
FacesContext fc = FacesContext.getCurrentInstance();
Application application = fc.getApplication();
dashboard = (Dashboard) application.createComponent(fc, "org.primefaces.component.Dashboard", "org.primefaces.component.DashboardRenderer");
dashboard.setId("dashboard");
DashboardModel model = new DefaultDashboardModel();
for( int i = 0; i < columnCount; i++ ) {
DashboardColumn column = new DefaultDashboardColumn();
model.addColumn(column);
}
dashboard.setModel(model);
view.setModel(dashboard.getModel());
view.setDashboard(dashboard);
int index = 0;
for( MonitorElement i : view.getUsersMonitorElements()) {
Panel panel = (Panel) application.createComponent(fc, "org.primefaces.component.Panel", "org.primefaces.component.PanelRenderer");
panel.setId("id" + i.getId());
panel.setHeader("Dashboard Component " + i.getApplicationName());
panel.setClosable(true);
panel.setToggleable(true);
dashboard.getChildren().add(panel);
DashboardColumn column2 = model.getColumn(index%columnCount);
column2.addWidget(panel.getId());
HtmlOutputText text = new HtmlOutputText();
text.setValue(i.getCount() + "" );
panel.getChildren().add(text);
index++;
}
view.setModel(dashboard.getModel());
view.setDashboard(dashboard);
}
I am implementing the dashboard on my index page using:
<p:dashboard id="dynamic_dashboard3"
binding="#{monitorView.dashboard}">
</p:dashboard>
Related
hello so I am trying to do a simulation using these two: jade Framework and cloudsim ToolKit
I am having this problem right here
what I am trying to do here is to get parameters to form the interface and then create my objects in this agent , then send them to another agent in ACLMessage which is another problem for me when it requires making the object I am trying to send( serialized ) please how can i do that i've got only 10 days left to give this project to my professor and this are not going well as u can see
Agent container Container-3#192.168.0.145 is ready.
--------------------------------------------
************************************************
Agent initialisation ......
Agent : AgentCME#192.168.0.145:1099/JADE is alive!
************************************************
Initialize the GridSim library
Starting The Interface
Interface Launched
************************************************
Starting SMA CME ...
Initialising...
Creating Cloud
data centre and broker created
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "Agent.AgentCME.onGuiEvent(jade.gui.GuiEvent)" because "this.ACME" is null
at IHM.Configuration.jButton6ActionPerformed(Configuration.java:1099)
at IHM.Configuration$10.actionPerformed(Configuration.java:543)
my agent class is here :
/**
*
* #author pc
*/
public class AgentCME extends GuiAgent {
// ref a l'interface graphique
transient protected StartingPage myGui ;
transient protected Configuration Conf;
#Override
protected void setup() {
if(getArguments().length==1){
Conf=(Configuration) getArguments()[0];
Conf.setACME(this);
}
System.out.println("************************************************");
System.out.println("Agent initialisation ...... ");
System.out.println("Agent : "+this.getAID().getName() + " is alive!");
System.out.println("************************************************");
System.out.println("Initialize the GridSim library");
System.out.println("Starting The Interface");
myGui = new StartingPage(this);
myGui.setSize(1024, 600);
myGui.setVisible(true);
Conf = new Configuration(this);
System.out.println("Interface Launched");
System.out.println("************************************************");
Log.printLine("Starting SMA CME ...");
CloudSim.init(1, Calendar.getInstance(), false);
// creating datacenters
Log.printLine("Creting Cloud");
datacenter0 = createDatacenter("DataCenter_0");
DatacenterBroker broker = createBroker("broker");
int brokerId = broker.getId();
Log.printLine("data centre and broker created");
}
#Override
#SuppressWarnings("empty-statement")
public void onGuiEvent(GuiEvent params) {
if (params.getType() == 3)
{
System.out.println("***************get Cloudlets configuration******************");
int cloudletsnmbr=(int) params.getParameter(0);
int length=(int) params.getParameter(1);
int fileSize=(int) params.getParameter(2);
int outputSize=(int) params.getParameter(3);
System.out.println("***params :"+cloudletsnmbr+"****"+length+"****"+fileSize+"****"+outputSize+"****");
System.out.println("***************Creating Cloudlet******************");
UtilizationModel utilizationModel = new UtilizationModelFull();
System.out.println("test");
Cloudlet cloudlet =
new Cloudlet(cloudletsnmbr, length,1, fileSize,
outputSize, utilizationModel, utilizationModel,
utilizationModel);
cloudletList = createCloudlet(broker.getId(),cloudletsnmbr);
System.out.println(cloudletList);
}
else if (params.getType() == 2)
{
System.out.println("***************get VM configuration******************");
int NmbrVm=(int) params.getParameter(0);
int RamVm=(int) params.getParameter(1);
int StorageVm=(int) params.getParameter(2);
int BwVm=(int) params.getParameter(3);
int MipsVm=(int) params.getParameter(4);
System.out.println("***************Creating VM list******************");
Vm vm = new Vm(NmbrVm,1, MipsVm,1, RamVm, BwVm, StorageVm, "Xen", new CloudletSchedulerTimeShared());
vmlist = createVM(broker.getId(), NmbrVm);
System.out.println(vmlist);
}else if (params.getType() == 1)
{
broker.submitVmList(vmlist);
broker.submitCloudletList(cloudletList);
CloudSim.startSimulation();
List<Cloudlet> newList = broker.getCloudletReceivedList();
CloudSim.stopSimulation();
printCloudletList(newList);
}
}
........
the interface code here :
protected AgentCME ACME ;
public Configuration ( Agent.AgentCME ui){
initComponents();
ACME = ui ;
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
//getting data frome interface...
StorageVm = Integer.parseInt(StorageVM.getText());
MipsVm = Integer.parseInt(MipsVM.getText());
NmbrVm = Integer.parseInt(NmbrVM.getText());
RamVm = Integer.parseInt(RamVM.getText());
BwVm = Integer.parseInt(BwVM.getText());
/*AgentCME.Setcloudlets(StorageVm);
AgentCME.Setcloudlets(MipsVm);
AgentCME.Setcloudlets(NmbrVm);
AgentCME.Setcloudlets(RamVm);
AgentCME.Setcloudlets(BwVm);*/
DefaultTableModel tblModel = (DefaultTableModel)VmTable.getModel();
for (int i = 0;i<NmbrVm;i++){
String data []= {"VM"+i,RamVM.getText(),StorageVM.getText(),BwVM.getText(),MipsVM.getText()};
tblModel.addRow(data);
}
GuiEvent event = new GuiEvent(this,2);
event.addParameter(NmbrVm);
event.addParameter(RamVm);
event.addParameter(StorageVm);
event.addParameter(BwVm);
event.addParameter(MipsVm);
ACME.onGuiEvent(event);
}
I choose Vaadin for building my very simple UI within the spring boot application.
I have:
#Route
#PWA(name = "Signing certificates manager", shortName = "CertMgr")
public class MainView extends VerticalLayout {
public MainView() {
Tab tab1 = new Tab("Certificates");
Tab tab2 = new Tab("Users");
Tabs tabs = new Tabs(tab1, tab2);
CertView certView = new CertView();
certView.setVisible(false);
UserView userView = new UserView(addUsers());
userView.setVisible(true);
Map<Tab, Component> tabsToPages = new HashMap<>();
tabsToPages.put(tab1, certView);
tabsToPages.put(tab2, userView);
Div pages = new Div(certView, userView);
Set<Component> pagesShown = Stream.of(userView)
.collect(Collectors.toSet());
tabs.addSelectedChangeListener(event -> {
pagesShown.forEach(page -> page.setVisible(false));
pagesShown.clear();
Component selectedPage = tabsToPages.get(tabs.getSelectedTab());
selectedPage.setVisible(true);
pagesShown.add(selectedPage);
});
add(tabs, pages);
}
private List<User> addUsers() {
return new LinkedList<User>() {{
add(new User("qewr", "asdf", "xzcv"));
}};
}
}
and
public class UserView extends VerticalLayout {
Grid<User> grid;
public UserView(List<User> users) {
grid = new Grid<>(User.class);
grid.setItems(users);
grid.addColumn(User::getMail).setHeader("mail");
grid.addColumn(User::getName).setHeader("name");
grid.addColumn(User::getPass).setHeader("pass");
grid.addSelectionListener(event -> {
List<User> selected = (List<User>) event.getAllSelectedItems();
add(new UserRow(selected.get(0)));
});
add(grid);
}
}
and the result of this is a view like this:
so you can see, the grid has no width and is too long (I have only one user there)
I am new to Vaadin so I am surely doing something wrong, but basically this is vaadin tabs handling from the samples.
My questions are:
how do I draw the grid properly with my current setup?
is it possible to display a view from completely different page when clicking on tab with that page would have it's own context and could use spring's DI? like to have autonomous page and not coupled objects like I have now. or advice the best pattern to handle this with vaadin, please.
Vaadin: 12.0.7
Spring-Boot: 2.1.2.RELEASE
Hope you get my point.
Thanks for advices!
just do
Div pages = new Div(certView, userView);
pages.setSizeFull();
I am developing a GWT app where I am using paging toolbar. When I have more than 10 groups in grid, user can go to second page with paging toolbar. But when I press button to go to the second page, it goes to that second, loading is shown but then toolbar is back to the first page with those first. 10 items.
This is first page:
And when I press button for second page I get this loading:
But then after that toolbar backs me to the first page. This is my class for paging toolbar:
public class MyPagingToolBar extends PagingToolBar {
private static final ConsoleMessages MSGS = GWT.create(ConsoleMessages.class);
public MyPagingToolBar(int pageSize) {
super(pageSize);
PagingToolBarMessages pagingToolbarMessages = getMessages();
pagingToolbarMessages.setBeforePageText(MSGS.pagingToolbarPage());
pagingToolbarMessages.setAfterPageText(MSGS.pagingToolbarOf().concat("{0}"));
StringBuilder sb = new StringBuilder();
sb.append(MSGS.pagingToolbarShowingPre())
.append(" {0} - {1} ")
.append(MSGS.pagingToolbarShowingMid())
.append(" {2} ")
.append(MSGS.pagingToolbarShowingPost());
pagingToolbarMessages.setDisplayMsg(sb.toString());
pagingToolbarMessages.setEmptyMsg(MSGS.pagingToolbarNoResult());
pagingToolbarMessages.setFirstText(MSGS.pagingToolbarFirstPage());
pagingToolbarMessages.setPrevText(MSGS.pagingToolbarPrevPage());
pagingToolbarMessages.setNextText(MSGS.pagingToolbarNextPage());
pagingToolbarMessages.setLastText(MSGS.pagingToolbarLastPage());
pagingToolbarMessages.setRefreshText(MSGS.pagingToolbarRefresh());
}
}
And this is class where I using MyPagingToolbar:
public abstract class EntityGrid<M extends GwtEntityModel> extends ContentPanel {
private static final ConsoleMessages MSGS = GWT.create(ConsoleMessages.class);
private static final int ENTITY_PAGE_SIZE = 10;
protected GwtSession currentSession;
private AbstractEntityView<M> parentEntityView;
private EntityCRUDToolbar<M> entityCRUDToolbar;
protected KapuaGrid<M> entityGrid;
protected BasePagingLoader<PagingLoadResult<M>> entityLoader;
protected ListStore<M> entityStore;
protected PagingToolBar entityPagingToolbar;
protected EntityFilterPanel<M> filterPanel;
protected EntityGrid(AbstractEntityView<M> entityView, GwtSession currentSession) {
super(new FitLayout());
//
// Set other properties
this.parentEntityView = entityView;
this.currentSession = currentSession;
//
// Container borders
setBorders(false);
setBodyBorder(true);
setHeaderVisible(false);
//
// CRUD toolbar
entityCRUDToolbar = getToolbar();
if (entityCRUDToolbar != null) {
setTopComponent(entityCRUDToolbar);
}
//
// Paging toolbar
entityPagingToolbar = getPagingToolbar();
if (entityPagingToolbar != null) {
setBottomComponent(entityPagingToolbar);
}
}
#Override
protected void onRender(Element target, int index) {
super.onRender(target, index);
//
// Configure Entity Grid
// Data Proxy
RpcProxy<PagingLoadResult<M>> dataProxy = getDataProxy();
// Data Loader
entityLoader = new BasePagingLoader<PagingLoadResult<M>>(dataProxy);
// Data Store
entityStore = new ListStore<M>(entityLoader);
//
// Grid Data Load Listener
entityLoader.addLoadListener(new EntityGridLoadListener<M>(this, entityStore));
//
// Bind Entity Paging Toolbar
if (entityPagingToolbar != null) {
entityPagingToolbar.bind(entityLoader);
}
//
// Configure columns
ColumnModel columnModel = new ColumnModel(getColumns());
//
// Set grid
entityGrid = new KapuaGrid<M>(entityStore, columnModel);
add(entityGrid);
//
// Bind the grid to CRUD toolbar
entityCRUDToolbar.setEntityGrid(this);
//
// Grid selection mode
GridSelectionModel<M> selectionModel = entityGrid.getSelectionModel();
selectionModel.setSelectionMode(SelectionMode.SINGLE);
selectionModel.addSelectionChangedListener(new SelectionChangedListener<M>() {
#Override
public void selectionChanged(SelectionChangedEvent<M> se) {
selectionChangedEvent(se.getSelectedItem());
}
});
//
// Grid view options
GridView gridView = entityGrid.getView();
gridView.setEmptyText(MSGS.gridEmptyResult());
//
// Do first load
refresh();
}
protected EntityCRUDToolbar<M> getToolbar() {
return new EntityCRUDToolbar<M>(currentSession);
}
protected abstract RpcProxy<PagingLoadResult<M>> getDataProxy();
protected PagingToolBar getPagingToolbar() {
return new MyPagingToolBar(ENTITY_PAGE_SIZE);
}
protected abstract List<ColumnConfig> getColumns();
public void refresh() {
entityLoader.load();
entityPagingToolbar.enable();
}
public void refresh(GwtQuery query) {
// m_filterPredicates = predicates;
setFilterQuery(query);
entityLoader.load();
entityPagingToolbar.enable();
}
public void setFilterPanel(EntityFilterPanel<M> filterPanel) {
this.filterPanel = filterPanel;
entityCRUDToolbar.setFilterPanel(filterPanel);
}
protected void selectionChangedEvent(M selectedItem) {
if (parentEntityView != null) {
parentEntityView.setSelectedEntity(selectedItem);
}
}
public void setPagingToolbar(PagingToolBar entityPagingToolbar) {
this.entityPagingToolbar = entityPagingToolbar;
}
public GridSelectionModel<M> getSelectionModel() {
return entityGrid.getSelectionModel();
}
protected abstract GwtQuery getFilterQuery();
protected abstract void setFilterQuery(GwtQuery filterQuery);
What is my mistake?
EDIT: This is my server method:
int totalLength = 0;
List<GwtGroup> gwtGroupList = new ArrayList<GwtGroup>();
try {
KapuaLocator locator = KapuaLocator.getInstance();
GroupService groupService = locator.getService(GroupService.class);
UserService userService = locator.getService(UserService.class);
GroupQuery groupQuery = GwtKapuaAuthorizationModelConverter.convertGroupQuery(loadConfig,
gwtGroupQuery);
GroupListResult groups = groupService.query(groupQuery);
if (!groups.isEmpty()) {
if (groups.getSize() >= loadConfig.getLimit()) {
totalLength = Long.valueOf(groupService.count(groupQuery)).intValue();
} else {
totalLength = groups.getSize();
}
for (Group g : groups.getItems()) {
gwtGroupList.add(KapuaGwtAuthorizationModelConverter.convertGroup(g));
for (GwtGroup gwtGroup : gwtGroupList) {
User user = userService.find(g.getScopeId(), g.getCreatedBy());
if (user != null) {
gwtGroup.setUserName(user.getDisplayName());
}
}
}
}
} catch (Exception e) {
KapuaExceptionHandler.handle(e);
}
return new BasePagingLoadResult<GwtGroup>(gwtGroupList, loadConfig.getOffset(),
totalLength);
}
(Didn't I just answer this an earlier version of this? Please don't delete questions after you get an answer to them, or people won't answer your questions at all any more.)
If the server is given a request for the second page (offset of 10), but returns a PagingLoadResult for the first page anyway, that is what you will see. Make sure your server is actually sending back the second page - not only that, but it must send in the response object the offset that it actually used for the next page (in your example, 10), or else the paging toolbar will not know which page the user is actually on.
Make sure the server is taking the request offset into account, and returning the parameters it used correctly to the client. If that appears to be correct, please add the server method to your question, and add logging on the client and server to verify what is being requested, vs what is being returned.
Skipping items in Java is pretty straightforward, but will not scale very well for huge lists.
In short, just skip the first offset items when looping.
First though, a free code review - this is very inefficient code - you are rewriting every item in gwtGroupList every time you add something:
for (Group g : groups.getItems()) {
gwtGroupList.add(KapuaGwtAuthorizationModelConverter.convertGroup(g));
for (GwtGroup gwtGroup : gwtGroupList) {
User user = userService.find(g.getScopeId(), g.getCreatedBy());
if (user != null) {
gwtGroup.setUserName(user.getDisplayName());
}
}
It could instead read:
for (Group g : groups.getItems()) {
gwtGroupList.add(KapuaGwtAuthorizationModelConverter.convertGroup(g));
}
for (GwtGroup gwtGroup : gwtGroupList) {
User user = userService.find(g.getScopeId(), g.getCreatedBy());
if (user != null) {
gwtGroup.setUserName(user.getDisplayName());
}
}
Alternatively, they could be just one loop.
Now we modify it again, to handle offset and limit:
int itemsLeftToSkip = offset;
for (Group g : groups.getItems()) {
if (itemsLeftToSkip > 0) {
itemsLeftToSkip--;
continue;//we skipped this item, and now the count is one less
}
if (gwtGroupList.size() >= limit) {
break;//we've got enough already, quit the loop
}
gwtGroupList.add(KapuaGwtAuthorizationModelConverter.convertGroup(g));
}
for (GwtGroup gwtGroup : gwtGroupList) {
User user = userService.find(g.getScopeId(), g.getCreatedBy());
if (user != null) {
gwtGroup.setUserName(user.getDisplayName());
}
}
Notice how we use offset to avoid items until we get to the ones that are needed for the new page, and we use limit to only send that many time, at a maximum.
Finally, unless your groupQuery already has a limit built in (in which case, you should put the offset there too...), the if (groups.getSize() >= loadConfig.getLimit()) { block of code is likely not necessary at all, since you've already loaded all items. If it is necessary because there is a limit, then your pages will not correctly load all the way to the end. Either way, investigate this code, and possibly get it reviewed further, something looks very wrong there.
I am using RealmRecyclerViewAdapter and is using RealmResult as my dataset.
Here's the Adapter code :
private RealmList<MessageItem> mDataset;
public ChatRoomAsUserAdapter(Context context, #Nullable RealmList<MessageItem> data) {
super(data, true);
this.context = context;
this.userId = Utilities.getUserInformation(context, SharedPreferencesList.userIDString);
this.mDataset = data;
}
Here's how I find the RealmResult in Activity for chat room initialization :
AppController.realm.beginTransaction();
// Getting chat inside the specific room id
ChatRoomWrapper chatFriendRealmResult = AppController.realm.where(ChatRoomWrapper.class)
.equalTo(ChatRoomWrapperFields.ROOM_ID, roomId).findFirst();
if (chatFriendRealmResult != null){
chatRoomAsUserAdapter = new ChatRoomAsUserAdapter(this, chatFriendRealmResult.message);
AppController.realm.commitTransaction();
}
...
After the initialization, I make an API call and in the result :
chatRoomWrapper.message.deleteAllFromRealm();
chatRoomWrapper.message.addAll(api.res.message_item_list);
Appcontroller.realm.copyToRealmOrUpdate(chatRoomWrapper);
And I get this error :
java.lang.ArrayIndexOutOfBoundsException: rowIndex is less than 0.
at io.realm.internal.LinkView.nativeGetTargetRowIndex(Native Method)
at io.realm.internal.LinkView.getTargetRowIndex(LinkView.java:82)
at io.realm.RealmList.get(RealmList.java:452)
Does that mean that the content of RV is changed unexpectedly? I am using RealmRecyclerViewAdapter which should handle that right?
UPDATE :
Here's an example on how I get the data :
getItem(position).getMsg_date();
where
public class MessageItem extends RealmObject {
...
public String msg_date = "";
}
EDIT :
This is how I update the adapter after getting information from server :
AppController.realm.beginTransaction();
// Create new ChatFriendWrapper and input the Room ID into it to update
// the Room ID if found
ChatRoomWrapper chatRoomWrapper = AppController.realm.where(ChatRoomWrapper.class)
.equalTo("room_id", roomId).findFirst();
if (chatRoomWrapper != null) {
if (output.flag.equals(Constants.flagRefresh)) {
counter = 0;
chatRoomWrapper.message.deleteAllFromRealm();
chatRoomWrapper.message.addAll(output.message_item_list);
MIApplication.realm.copyToRealmOrUpdate(chatRoomWrapper);
manager.scrollToPosition(0);
} else if (output.flag.equals(Constants.flagLoad)) {
chatRoomWrapper.message.addAll(output.message_item_list);
AppController.realm.copyToRealmOrUpdate(chatRoomWrapper);
}
} else {
ChatRoomWrapper newChatRoomWrapper = new ChatRoomWrapper();
newChatRoomWrapper.room_id = roomId;
newChatRoomWrapper.message.addAll(output.message_item_list);
AppController.realm.copyToRealmOrUpdate(newChatRoomWrapper);
setupChatRoom();
}
AppController.realm.commitTransaction();
The culprit was the usage of position instead of holder.getAdapterPosition() to get the item. I used to do this :
viewholder.message.setText(getItem(position).message);
now it's
viewholder.message.setText(getItem(holder.getAdapterPosition()).message);
And it cleared the error. I suddenly remember when I used to have problems with infinite scrolling in RecyclerView, I came across this kind of error too.
I'm trying to build grid with build in column filtering (using sencha gxt), here is my code:
public Grid<Stock> createGrid() {
// Columns definition
ColumnConfig<Stock, String> nameCol = new ColumnConfig<Stock, String>(props.name(), 100, "Company");
// Column model definition and creation
List<ColumnConfig<Stock, ?>> cl = new ArrayList<ColumnConfig<Stock, ?>>();
cl.add(nameCol);
ColumnModel<Stock> cm = new ColumnModel<Stock>(cl);
// Data populating
ListStore<Stock> store = new ListStore<Stock>(props.key());
store.addAll(TestData.getStocks());
// Grid creation with data
final Grid<Stock> grid = new Grid<Stock>(store, cm);
grid.getView().setAutoExpandColumn(nameCol);
grid.setBorders(false);
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
// Filters definition
StoreFilterField<Stock> filter = new StoreFilterField<Stock>() {
#Override
protected boolean doSelect(Store<Stock> store, Stock parent, Stock item, String filter) {
// Window.alert(String.valueOf("a"));
String name = item.getName();
name = name.toLowerCase();
if (name.startsWith(filter.toLowerCase())) {
return true;
}
return false;
}
};
filter.bind(store);
cm.addHeaderGroup(0, 0, new HeaderGroupConfig(filter, 1, 1));
filter.focus();
return grid;
}
My problem is: after I run this code, I cannot write anything to filter input, I'm using test data and classes (Stock.java and StockProperties.java) from this example: http://sencha.com/examples-dev/#ExamplePlace:filtergrid
I try to put allert in doSelect method to check if this function was called, but it wasn't.
Any idea will be welcome. Thanks.
I was able to make your code work. I observed that there were compiler errors in the code for StoreFilterField class. Here is the code that filters the grid based on the values in the first column, that is, name field in the Stock model.
StoreFilterField<Stock> filter1 = new StoreFilterField<Stock>() {
#Override
protected boolean doSelect(Store<Stock> store, Stock parent, Stock record, String property, String filter) {
String name = record.get("name");
name = name.toLowerCase();
if (name.startsWith(filter.toLowerCase())) {
return true;
}
return false;
}
};
filter1.bind(store);
Btw, I tested this with GXT 2.2.5 and GWT 2.4.
Thanks,
Ganesh
I solve this problem according to this paper http://www.sencha.com/forum/archive/index.php/ … but I replace disableTextSelection(false) with setAllowTextSelection(true);