JQGrid is not showing any data content

9 views
Skip to first unread message

Vid Cheruvu

unread,
Sep 24, 2010, 1:54:52 AM9/24/10
to wiquery-plugins
Hi,

I have checked out your jqGrid source code and built the jar using mvn
install command. I have tried to use jqgrid-1.0-SNAPSHOT jar in my
Wicket application. I wrote my DataProvider class that connects to my
database and successfully returns Iterator list to GridDataPanel for
cell item population. However when the panel is rendered i see jqgrid
with empty rows. I have also checked that GridXMLData.getXML() returns
the xml content back to ajax requestor. I have pasted my code below.
Could you please tell me if I am missing anything in my code in order
to be able to display data on jqgrid?


public class MapInstrumentSymbolPanel extends Panel{


@SpringBean
private IFutExeInstrumentSymbolRepo futExeInstrumentSymbolRepo;

WebMarkupContainer context;

public MapInstrumentSymbolPanel(String id) {
super(id);


FutExeInstrumentProvider futexeInstrumentProvider = new
FutExeInstrumentProvider(futExeInstrumentSymbolRepo);

GridModel<FutExeInstrumentSymbolEntity> gridModel = new
GridModel<FutExeInstrumentSymbolEntity>(FutExeInstrumentSymbolEntity.class);
createColumns(gridModel);
Grid<FutExeInstrumentSymbolEntity> futexeInstrumentSymbolGrid = new
Grid<FutExeInstrumentSymbolEntity>("grid", gridModel,
futexeInstrumentProvider);

context = new WebMarkupContainer("context");
context.setOutputMarkupId(true);
add(context);
context.add(futexeInstrumentSymbolGrid);
}

private void createColumns(GridModel<FutExeInstrumentSymbolEntity>
gridModel) {

gridModel.addColumnModel(new
GridColumnModel<FutExeInstrumentSymbolEntity>("instrumentID","InstrumentID" ,new
Model<String>("InstrumentID"), 200));
gridModel.addColumnModel(new
GridColumnModel<FutExeInstrumentSymbolEntity>("symbol","Symbol" ,new
Model<String>("Symbol"), 200));
gridModel.addColumnModel(new
GridColumnModel<FutExeInstrumentSymbolEntity>("symbolSet","SymbolSet" ,new
Model<String>("SymbolSet"), 200));
gridModel.addColumnModel(new
GridColumnModel<FutExeInstrumentSymbolEntity>("symbolType","SymbolType" ,new
Model<String>("SymbolType"), 200));
gridModel.setRowNum(10);
gridModel.setScroll(10);
gridModel.setCaption("FutExeInstrumentSymbolEntity");
}

}


public class FutExeInstrumentProvider extends
ListDataProvider<FutExeInstrumentSymbolEntity>
implements
ISortableDataProvider<FutExeInstrumentSymbolEntity>,IFilterStateLocator{

/**
*
*/
private static final long serialVersionUID = 7372470305593368776L;
private QueryParam queryParam;
private SingleSortState state = new SingleSortState();
private IFutExeInstrumentSymbolRepo futExeInstrumentSymbolRepo;
private List futexeSymbolList;
FutExeInstrumentSymbolEntity futExeInstrumentFilter = new
FutExeInstrumentSymbolEntity();

public FutExeInstrumentProvider(IFutExeInstrumentSymbolRepo
repository) {
this.futExeInstrumentSymbolRepo = repository;
state.setPropertySortOrder("InstrumentID", ISortState.ASCENDING);
String extracClause = sortAndFilter(0, 10, false);
String sql = "Select Symbol,SymbolType,SymbolSet,InstrumentID from
FutExe_InstrumentSymbol " + extracClause ;
futexeSymbolList =
futExeInstrumentSymbolRepo.callPagingationQuery(sql, 0, 10);
}

@Override
public Object getFilterState() {
return futExeInstrumentFilter;
}

@Override
public void setFilterState(Object state) {
this.futExeInstrumentFilter = (FutExeInstrumentSymbolEntity) state;

}

@Override
public Iterator<? extends FutExeInstrumentSymbolEntity> iterator(int
first, int count) {
final SortParam sp = state.getSort();
if (queryParam == null)
{
queryParam = new QueryParam(first, count, sp.getProperty(),
sp.isAscending());
}
else
{
queryParam.setFirst(first);
queryParam.setCount(count);
queryParam.setSort(sp.getProperty());
queryParam.setSortAsc(sp.isAscending());
}

String extracClause = sortAndFilter(first, count, false);
/*List<FutExeInstrumentSymbolEntity> lst =
futExeInstrumentSymbolRepo.adhocQuery(
"Select * from FutExe_InstrumentSymbol " + extracClause ,
queryParam.getFirst(),queryParam.getCount());
*/
String sql = "Select Symbol,SymbolType,SymbolSet,InstrumentID from
FutExe_InstrumentSymbol " + extracClause ;
List<FutExeInstrumentSymbolEntity> lst =
futExeInstrumentSymbolRepo.callQuery(sql, queryParam.getFirst(),
queryParam.getCount());
return lst.listIterator();
};


protected String sortAndFilter(int index, int count,boolean
pagingEnabled) {
StringBuilder matchStringbuffer = new StringBuilder();
StringBuilder orderByStringbuffer = new StringBuilder();
if(futExeInstrumentFilter != null){

Integer instrumentID = futExeInstrumentFilter.getInstrumentID();
String symbol = futExeInstrumentFilter.getSymbol();
String symbolSet = futExeInstrumentFilter.getSymbolSet();
boolean requireAnd = false;
boolean requireWhere = true;
if( instrumentID != null && instrumentID.intValue() > 0 ){
if(requireWhere) appendWhereToBuffer(matchStringbuffer);
matchStringbuffer.append(" where");
matchStringbuffer.append("InstrumentID = " +
futExeInstrumentFilter );
requireAnd = true;
requireWhere=false;
}
if(symbolSet != null && !symbolSet.equalsIgnoreCase("")) {
if(requireWhere) appendWhereToBuffer(matchStringbuffer);
if(requireAnd) appendAndToBuffer(matchStringbuffer);
matchStringbuffer.append(" SymbolSet = '" +
futExeInstrumentFilter.getSymbolSet()+"'" );
requireAnd = true;
requireWhere=false;
}
if(symbol != null && !symbol.equalsIgnoreCase("")) {
if(requireWhere) appendWhereToBuffer(matchStringbuffer);
if(requireAnd) appendAndToBuffer(matchStringbuffer);
matchStringbuffer.append(" Symbol like '%" +
futExeInstrumentFilter.getSymbol() + "%' " );
}

}
if( queryParam != null) {
addOrderByClause(orderByStringbuffer);
}
String extraClause =
matchStringbuffer.append(orderByStringbuffer).toString();


return extraClause;

}

void appendAndToBuffer(StringBuilder sb){
sb.append(" AND ");
}
void appendWhereToBuffer(StringBuilder sb){
sb.append(" Where ");
}

private void addOrderByClause(StringBuilder hql) {
if ( queryParam != null && queryParam.hasSort()) {
hql.append(" order by ");
//hql.append(" SeqNumber, ");
hql.append(queryParam.getSort());
hql.append(" ");
hql.append(queryParam.isSortAsc() ? "asc" : "desc");
}
}

@Override
public int size() {
String extraClause = sortAndFilter(0,0, false);
return futExeInstrumentSymbolRepo.count(extraClause);
}

@Override
public IModel<FutExeInstrumentSymbolEntity>
model(FutExeInstrumentSymbolEntity object) {
return new DetachableFutExInstSymbolEntityModel(object,
futExeInstrumentSymbolRepo);
}


@Override
public ISortState getSortState() {
return state;

}

@Override
public void setSortState(ISortState state) {
this.state = (SingleSortState)state;
}
}



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.sourceforge.net/" xml:lang="en"
lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<title>Data Grid</title>
</head>
<body>
<wicket:panel>
<div wicket:id="context">
<div wicket:id="grid"></div>
</div>
</wicket:panel>
</body>
</html>




Ernesto Reinaldo Barreiro

unread,
Sep 24, 2010, 2:14:48 AM9/24/10
to wiquery...@googlegroups.com
Can you provide me with quick-start project to test this? Does this
happens for all browsers or only for a particular "brand" (e.g. IE,
FF).

Ernesto

Reply all
Reply to author
Forward
0 new messages