PDA

View Full Version : How to show Pop up on one of cells inside a Grid



myworld100us
29 Aug 2009, 11:20 PM
I am using GXT Grid . I have got the values displayed . There is a requirement that one of collumns of the cell should open a pop up window . I dont know how to do it . I used Cell Renderer. The below code does not work . Can anyone help me on this

ColumnConfig column = new ColumnConfig("student", "Student", 55);
GridCellRenderer<BaseModel> catNo = new GridCellRenderer<BaseModel>() {
public String render(BaseModel model, String property, ColumnData config, int rowIndex,
int colIndex, ListStore<BaseModel> store, Grid<BaseModel> grid) {
String val = (String) model.get(property);
return "<a href=javascript:window.open('myApp/showDetails.jsp';>"+val+"</a>";
}
};
column.setAlignment(HorizontalAlignment.RIGHT);
column.setRenderer(catNo);

EdwinK
30 Aug 2009, 8:50 AM
Take a look at this sample:
http://www.extjs.com/examples/#widgetrenderergrid

In that sample a column of the grid contains a button, that (on click) opens a display-window, but you can change the display-window to any other window.

Arno.Nyhm
31 Aug 2009, 4:46 AM
The below code does not work .

what you mean with dows not work?

a) not rendered
b) not open a window?
c) not display the right data
d) other __________________






ColumnConfig column = new ColumnConfig("student", "Student", 55);
GridCellRenderer<BaseModel> catNo = new GridCellRenderer<BaseModel>() {
public String render(BaseModel model, String property, ColumnData config, int rowIndex,
int colIndex, ListStore<BaseModel> store, Grid<BaseModel> grid) {
String val = (String) model.get(property);
return "<a href=javascript:window.open('myApp/showDetails.jsp';>"+val+"</a>";
}
};
column.setAlignment(HorizontalAlignment.RIGHT);
column.setRenderer(catNo);


many things i am misssing in this line:


return "<a href=javascript:window.open('myApp/showDetails.jsp';>"+val+"</a>";possible problems
a) you not enclose the href with "
b) there is no closing ")"
c) you dont give any value to the calling jsp file.
d) missing "return false" to not reload the page after the click (sometimes you need this)


possible working:


return "<a href=\"javascript:window.open('myApp/showDetails.jsp?myvalue=" + val +"');return false;\" >"+val+"</a>";

myworld100us
31 Aug 2009, 10:23 AM
Arno ,

I tried your solution also . Even that does not open up a pop up . When i Click on the collumn from inisde a grid , nothing happens . When i do a right click open in new window , just to test it a blank page opens up with everything from javascript:window. open ..... the url . Am i missing something else .

Arno.Nyhm
1 Sep 2009, 5:12 AM
can you pls post your changed current code? and a full working example like in the bugforum guidelines. then i easy test your problem