Guest User

Untitled

a guest
Jan 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. listExtendRecords($records)
  2.  
  3. $new = new Production();
  4. return $new;
  5.  
  6. ....
  7. toolbar:
  8. buttons: list_toolbar
  9. search:
  10. prompt: 'backend::lang.list.search_prompt'
  11. recordUrl: 'hardiksatasiya/demotest/demo/update/:id'
  12. // add customViewPath
  13. customViewPath: $/hardiksatasiya/demotest/controllers/demo/list_override
  14.  
  15. _list_body_rows.htm
  16. _list_body_row.htm
  17.  
  18. <?php foreach ($records as $record): ?>
  19. <?= $this->makePartial('list_body_row', [
  20. 'record' => $record,
  21. 'treeLevel' => $treeLevel,
  22. 'custom' => isset($custom) ? true : false])
  23. ?>
  24. <?php endforeach ?>
  25.  
  26. <?php
  27. $expanded = $showTree ? $this->isTreeNodeExpanded($record) : null;
  28. $childRecords = $showTree ? $record->getChildren() : null;
  29. $treeLevelClass = $showTree ? 'list-tree-level-'.$treeLevel : '';
  30. ?>
  31. <tr class="<?= $treeLevelClass ?> <?= $this->getRowClass($record) ?>">
  32. <!-- we are using that custom variable here we dont want to show check box for our products-->
  33. <?php if ($showCheckboxes && $custom == false): ?>
  34. <?= $this->makePartial('list_body_checkbox', ['record' => $record]) ?>
  35. <?php endif ?>
  36.  
  37. <?php if ($showTree): ?>
  38. <?= $this->makePartial('list_body_tree', [
  39. 'record' => $record,
  40. 'expanded' => $expanded,
  41. 'childCount' => $record->getChildCount()
  42. ]) ?>
  43. <?php endif ?>
  44.  
  45. <!-- we are using that custom variable here
  46. and make our row seperatly as we need
  47. for all item/product record this partial executed so
  48. we code it for single row it will be repeated through all product items automatically-->
  49. <?php if($custom): ?>
  50. <td> <!-- checkbox column we make it blank--> </td>
  51. <!-- colspan based on requirement -->
  52. <td colspan="<?= count($columns) ?>"> <a href="/backend/products/edit/<?= $record->id ?>"> <?= $record->name ?> </a></td>
  53.  
  54. <?php else: ?>
  55.  
  56. <?php $index = $url = 0; foreach ($columns as $key => $column): ?>
  57. <?php $index++; ?>
  58. <td class="list-cell-index-<?= $index ?> list-cell-name-<?= $column->getName() ?> list-cell-type-<?= $column->type ?> <?= $column->clickable ? '' : 'nolink' ?> <?= $column->cssClass ?>">
  59. <?php if ($column->clickable && !$url && ($url = $this->getRecordUrl($record))): ?>
  60. <a <?= $this->getRecordOnClick($record) ?> href="<?= $url ?>">
  61. <?= $this->getColumnValue($record, $column) ?>
  62. </a>
  63. <?php else: ?>
  64. <?= $this->getColumnValue($record, $column) ?>
  65. <?php endif ?>
  66. </td>
  67. <?php endforeach ?>
  68.  
  69. <?php endif; ?>
  70.  
  71. <?php if ($showSetup): ?>
  72. <td class="list-setup">&nbsp;</td>
  73. <?php endif ?>
  74. </tr>
  75.  
  76. <?php if ($showTree && $expanded): ?>
  77. <?= $this->makePartial('list_body_rows', ['records' => $childRecords, 'treeLevel' => $treeLevel+1]) ?>
  78. <?php endif ?>
  79.  
  80. <!-- you can customise this condition basde on your order have items or not
  81. i used simple relation condition here -->
  82. <?php if ($record->relation): ?>
  83.  
  84. <?php $childRecords = is_array($record->relation) ? $record->relation : [$record->relation]; ?>
  85. <?php
  86. // currently as $childRecords i used relation but you can create your own model array
  87. // and pass here it will be received in next iteration
  88. // notice we are passing $custom variable and we also override
  89. // _list_body_rows.htm and it will loop through all records and pass
  90. // $custom variable and it will be true based on its existance
  91. // if we pass custom variable it will pass it also with true other wise
  92. // it will pass it false
  93. ?>
  94.  
  95. <?= $this->makePartial('list_body_rows', ['records' => $childRecords, 'treeLevel' => $treeLevel+1, 'custom' => true]) ?>
  96. <?php endif ?>
Add Comment
Please, Sign In to add comment