Add / Duplicate row data with Grid or Listbox
Hi,
Would you provide your implementation? Then we can give some advice.
Hi Vincent,
Our client receives quotations in excel sheets, but , content format varies ( order of columns, title name of column.. ). We need to insert a single quotation (many products . one product in a row with many columns ) to a standard grid ( We implemented this part ).
Customer want to approve , reject or comment each row. Also they need to copy single row with data and want to insert next to the copied row with same data ( it should be editable too ). This is for adding product with similar specifications .
In each row , we need to put a approve / reject .
Please help us for this.
Hi,
There are two demo about inline edit for grid.
Please refer to the link: http://www.zkoss.org/zkdemo/grid/inline_editing and http://www.zkoss.org/zkdemo/grid/inline_row_editing.
And you could implement ListModelList.add() API for adding duplicate row data.
Hi Vincent,
We had tried this already. This does not helps to insert a " NEW ROW " at desired position . We actually need to DUPLICATE a row with existing data , at desired position.
Eg: We need insert a 5th row with the data in 4th row. So 4th and 5th will have the same data.
Hi,
As I mentioned in last post. You can implement ListModelList.add() API to add duplicate data.
For example:
public void onClick$copyBtn() {
ListModelList listModel = (ListModelList) grid.getModel();
Object rowData4 = listModel.get(4);
listModel.add(rowData4);
}
Hi Vincent,
I using ZK 5.0.7.1 had try your last solution but I want to apply with listbox which with button event OnClick it add one row below but it has empty content.
Regards
Hi,
Here is the demo I tried and works fine
TestComposer.java
package jdflgf7$v6;import org.zkoss.zk.ui.*;
import org.zkoss.zk.ui.event.*;
import org.zkoss.zk.ui.util.*;
import org.zkoss.zk.ui.ext.*;
import org.zkoss.zk.au.*;
import org.zkoss.zk.au.out.*;
import org.zkoss.zul.*;public class TestComposer extends GenericForwardComposer {
private Grid grid;
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
String[] items = new String[]{"item 1", "item 2", "item 3", "item 4", "item 5"};
grid.setModel(new ListModelList(items));
grid.setRowRenderer(new RowRenderer(){
public void render(Row row, Object data) {
String item = (String) data;
new Label(item).setParent(row);
}
});
}
public void onClick$copy() {
ListModelList listModel = (ListModelList) grid.getModel();
int size = listModel.size();
String item6 = ((String) listModel.get(size-1)) + " copy ";
listModel.add(item6);
}
}
index.zul
<zk>
<window border="normal" title="hello" apply="jdflgf7$v6.TestComposer">
<grid id="grid">
<columns>
<column label="items" />
</columns>
</grid>
<button id="copy" label="copy last row" />
</window>
</zk>
ZK - Open Source Ajax Java Framework
We want to duplicate editable row with data. We prefer to use grid or list box. Tried a lot of ways. Please help us to do
1. Read data from a grid
2. Duplicate row with multi columns ( it should be editable too after adding the row )