Hi,
Is it possible to copy a pre existing grid on the page on a button press,my requirement is that a user presses a button and a copy of the current grid is creatd on the page along side the original grid.
Is there some way I can do that.?
Hello,
I don't think if there is a dirrect way to achieve it because no cloning information is available for the grid. Also adding the grid on button click to the view (dynamically) is not feasible because you need to do all the stuff (adding exact column and datasource fetched from the existing grid).
Thank you
Roshan
Actually I think you can do this - but as Roshan says, you'll need the column names etc to get it right.
What exactly is this for? I can give you more edvice if I have a more detailed understanding of your needs.
Thanks,Jim
Actually I am trying to create a page that will be used by the users to fill in some data and the tables will be grids instead of plain HTML tables.
I need to provide the user the functionality to create the same grid on the page if in case he needs to put in data that is similar in type but not exactly same.
I have attached a sample image, the second grid is a copy of the first grid, however the data source of the copied grid needs to be different as the new data entered will also need to seprately manipulated later.
Sure, but I want to make sure that I'm understanding the issue you're facing.
The grid gets its data from a collection type, usually an ArrayList. The ArrayList contains ordinary Java Beans - these are the objects that will provide you with your getters and setters. So when you said:
"Although creating a Arraylist at at run time is not a problem , the problem comes as there are no getters/setters for the newly created list."
I thought I should point out that the getters and setters aren't in the ArrayList object, they are in teh ebans that the ArrayList holds.
Is this the problem, or have I misunderstood you?
Jim:
I could not understand clearly what you meant above.
Can u pls clarify a bit..??
Well, the ArrayList needs to be populated with Beans - the Grid will pull its columns from the getters and setters in the Bean, not in the ArrayList itself.
Then when you're building the grid, you will need to assign the attribute from the bean to a column. To do this use the setUnifiedValueExpression. This method is in the UnifiedColumn class, which is an ancestor of both HtmlColumn and Column.
setUnifiedValueExpression.
UnifiedColumn class,
HtmlColumn
Column.
Best,Jim
I have been able to create a grid on the page dynamically using Java code, the problem I am facing now is that, since the no. of grids is not fixed I need to create a new data source at run time.
Although creating a Arraylist at at run time is not a problem , the problem comes as there are no getters/setters for the newly created list.
I will be highly obliged if you could give me some suggestions or pointers for solviong this problem.
Another query that I had is:
In a simple grid that I created, even when I edit the values of a cell, the setter for the list is never called but the edited values are always available in the list. Please tell me how this works.
Regards,
Avijit
Avijit:
Sure. When you create a grid as a server-side object, its not really connected to the browser. So to get it to appear on the page, you have to connect it to a tag in teh JSP.
Since you're going to have several grids - and since the number of grids needs to change synamically, you're going to need a container object (like an h:panelGrid on your page. You must bind the panel to the server and then you can add your grids to the panel, as children.
When you add the panle to the page, be sire to use a binding attribute to connect it to a server-side attribute.