smartgwtee-2.3
FireFox 3.5.9 ( linux )
No server side.
Client side no javascript errors or warnings
I hope you cant understand me with my poor English.
I have a GRID and the application fetch the data from my mysql DB.
The problem is that when i setGroupByField the filtering stop working but if i disable it, the filtering works again.
Is it possible to Group and filter in a list grid?
wich is my error?
The code is a little messy but i'ts understandable "i I think"
greetings
FireFox 3.5.9 ( linux )
No server side.
Client side no javascript errors or warnings
I hope you cant understand me with my poor English.
I have a GRID and the application fetch the data from my mysql DB.
The problem is that when i setGroupByField the filtering stop working but if i disable it, the filtering works again.
Is it possible to Group and filter in a list grid?
wich is my error?
The code is a little messy but i'ts understandable "i I think"
greetings
Code:
package com.smartgwt.sample.client; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.Record; import com.smartgwt.client.data.RestDataSource; import com.smartgwt.client.data.fields.DataSourceDateField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.widgets.form.SearchForm; import com.smartgwt.client.widgets.form.fields.ButtonItem; import com.smartgwt.client.widgets.form.fields.CheckboxItem; import com.smartgwt.client.widgets.form.fields.HeaderItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.events.RecordClickEvent; import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.layout.VStack; import com.smartgwt.client.widgets.tab.Tab; import com.smartgwt.client.widgets.tab.TabSet; import com.smartgwt.client.widgets.viewer.DetailViewer; public class ConsulPer { public static VStack vstack; private ButtonItem findItem; final SearchForm searchForm = new SearchForm(); final ListGrid listGrid = new ListGrid(); public static ConsulPer instance = null; public static VStack getInstance() { if ( instance == null ){ instance = new ConsulPer(); } return vstack; } public ConsulPer(){ // Creo los layouts para el formulario // y los botones del formulario // vstack = new VStack(); vstack.setMembersMargin(5); final DetailViewer itemViewer = new DetailViewer(); // // creo el datasource del formulario // RestDataSource dataSource = new RestDataSource(); dataSource.setDataFormat(DSDataFormat.JSON); dataSource.setDataURL("http://nuovamed.com/getAfil.php"); DataSourceTextField dni = new DataSourceTextField("dni", "DNI", 50, true); dni.setPrimaryKey(true); DataSourceTextField nombre = new DataSourceTextField("nombre", "NOMBRE", 50, true); DataSourceTextField domicilio = new DataSourceTextField("domicilio", "DOMICILIO", 100, false); DataSourceTextField telefono = new DataSourceTextField("telefono", "TELEFONO"); DataSourceDateField fnac = new DataSourceDateField("fnac", "F.NACIMIENTO", 100, true); DataSourceTextField dnititular = new DataSourceTextField("dnit", "DNI Titular", 50, true); DataSourceTextField nafilfield = new DataSourceTextField("nafil", "Nš AFIL", 50, false); DataSourceTextField empresafield = new DataSourceTextField("empresa", "EMPRESA", 50, true); dataSource.setFields(dni, nombre, domicilio, fnac, telefono, dnititular, nafilfield, empresafield); // //creo el formulario searchForm // vstack.addMember(searchForm); //tabLabel.addChild(searchForm); searchForm.setWidth100(); searchForm.setTop(5); searchForm.setBackgroundColor("#EEFFFF"); searchForm.setGroupTitle("Busqueda"); searchForm.setIsGroup(true); searchForm.setCellPadding(15); searchForm.setNumCols(7); searchForm.setDataSource(dataSource); searchForm.setUseAllDataSourceFields(false); TextItem searchFormField = new TextItem("dni"); searchFormField.setWidth(200); TextItem searchFormAfil = new TextItem("nafil"); searchFormAfil.setWidth(200); CheckboxItem findInCategory = new CheckboxItem("findInCategory"); findInCategory.setTitle("Titulares"); findInCategory.setDefaultValue(true); findInCategory.setShouldSaveValue(false); HeaderItem header = new HeaderItem(); header.setDefaultValue("Busqueda de afiliados"); findItem = new ButtonItem("Buscar"); findItem.setWidth(70); findItem.setEndRow(false); findItem.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { findItems(null); } }); searchForm.setItems(findItem, searchFormField, searchFormAfil, findInCategory); // // Creo el ItemListGrid // listGrid.setWidth100(); listGrid.setHeight(250); listGrid.setGroupByField("empresa"); listGrid.setDataSource(dataSource); listGrid.setCanEdit(true); listGrid.setAutoFetchData(true); listGrid.addRecordClickHandler(new RecordClickHandler() { public void onRecordClick(RecordClickEvent event) { Record selectedRecord = listGrid.getSelectedRecord(); itemViewer.setData(new Record[]{selectedRecord}); } }); vstack.addMember(listGrid); ListGridField dniGrid = new ListGridField("dni", "DNI"); ListGridField dnitGrid = new ListGridField("dnit", "DNI Titular"); ListGridField nafilGrid = new ListGridField("nafil", "Nš AFIL"); ListGridField nombreGrid = new ListGridField("nombre", "Nombre"); ListGridField domGrid = new ListGridField("domicilio", "Domicilio"); ListGridField telGrid = new ListGridField("telefono", "Telefono"); ListGridField fnacGrid = new ListGridField("fnac", "F.Nacimiento"); ListGridField empresaGrid = new ListGridField("empresa", "Empresa"); listGrid.setFields(dniGrid, dnitGrid, nafilGrid, nombreGrid, domGrid, telGrid, fnacGrid, empresaGrid); TabSet tabDetail = new TabSet(); itemViewer.setDataSource(dataSource); itemViewer.setWidth100(); itemViewer.setMargin(0); itemViewer.setEmptyMessage("Elegir un registro para ver"); Tab viewTab = new Tab("View"); viewTab.setWidth(70); viewTab.setPane(itemViewer); Tab editTab = new Tab("Edit"); editTab.setWidth(70); //editTab.setPane(editorForm); tabDetail.setTabs(viewTab, editTab); tabDetail.setHeight(200); vstack.addMember(tabDetail); } public void findItems(String categoryName) { Criteria findValues; findValues = searchForm.getValuesAsCriteria(); listGrid.filterData(findValues); } }