Guest User

Untitled

a guest
Nov 4th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. ### Requirements:
  2. I want to create a group model list which will able to render quickly at least 500 rows without pagination and fixed height.
  3. i have following 4 functionality with this group model:
  4.  
  5. - Add: i can add one or many items to the list by a global level button
  6. - Delete: i can delete a particular item from the list by row level button
  7. - Edit: i can edit the whole list by a single global level button
  8. - Expand/Collapse: Able to expand/collapse the whole list group with a global level button
  9.  
  10. ### Approach:
  11. As browser is getting hanged while rendering 500 rows, so i decided the following approach:
  12. - If i have more than 100 rows to render in the list group, i will collapse all groups with defering the children. When i expand a particular group, then it's children will render.
  13.  
  14. Here is the listbox with grouping example, i also try the same with grid. i tried with the group model with AbstractGroupsModel, GroupsModelArray, SimpleGroupsModel implementations. Actually i need an auto-notifiable GroupModel like ListModelList(In case of simple listbox) in any operations(add, edit and delete).
  15. ``` html
  16. <listbox model="@load(vm.employeeGroupModel)" >
  17. <listhead sizable="true">
  18. <listheader label="Header1" width="20%"></listheader>
  19. <listheader label="Header2" width="20%"></listheader>
  20. ...
  21. </listhead>
  22. <template name="model:group">
  23. <listgroup label="@load(each)" open="true"/>
  24. </template>
  25. <template name="model">
  26. <listitem fulfill="self.what.onOpen">
  27. <listcell>
  28. <!-- Each listcell has two componenents, If user click on edit button, the edtable component will display -->
  29. <label visible="@bind(!vm.editMode)" value="@load(each.empId)"></label>
  30. <textbox visible="@bind(vm.editMode)" value="@load(each.empId)"></textbox>
  31. </listcell>
  32. <listcell>
  33. <label visible="@bind(!vm.editMode)" value="@load(each.joiningDate)"></label>
  34. <datebox visible="@bind(vm.editMode)" value="@load(each.joiningDate)"></datebox>
  35. </listcell>
  36. ...
  37. </listitem>
  38. </template>
  39. </listbox>
  40. ```
  41.  
  42. ### Issues:
  43.  
  44. 1. Unable to apply fulfill attribute in listitem component.
  45. 2. If i will be able to apply this attribute, then how i can make this in conditional basis. Means if i have less than 100 rows, then fulfill attribute should not apply and all the listgroups should render in expand mode.
  46. 3. During add a new item or delete a item, i need to notify the whole groupModel which taking more time to repaint the DOM.
  47. 4. i am facing an issue during expand/collapse. Some of the listgroup is not expanding/collapsing if i have large number of rows. i have the following logic for expanding/collapsing:
  48.  
  49. ``` java
  50. private void collapseAll() {
  51. List<Listitem> items = listbox.getItems();
  52. for (Listitem listitem : items) {
  53. if(listitem instanceof Listgroup) {
  54. ((Listgroup)listitem).setOpen(false);
  55. }
  56. }
  57. }
  58.  
  59. private void expandAll() {
  60. List<Listitem> items = listbox.getItems();
  61. for (Listitem listitem : items) {
  62. if(listitem instanceof Listgroup) {
  63. ((Listgroup)listitem).setOpen(true);
  64. }
  65. }
  66. }
  67.  
  68. ```
Add Comment
Please, Sign In to add comment