Creating editable form table using Buffer Data Provider in VBCS (Part2)
This is a continuation of previous blog.
- Now add another blank column to the table where we will later add the edit row button to edit the respective row
- Create an ANY type of variable editRow and assign the same to edit-row property of the table
- Modify edit-mode to rowEdit
- Create an object rowData having same type as the Employee data to store user updates on ui
- Create rowTemplate inside the table as shown below to display rows in navigation and edit mode
<template slot="rowTemplate" data-oj-as="row"><tr><!-- ko if: row.mode === "navigation" --><td><oj-bind-text value="[[row.item.data.FirstName]]"></oj-bind-text></td><td><oj-bind-text value="[[row.item.data.LastName]]"></oj-bind-text></td><td><oj-bind-text value="[[row.item.data.PhoneNumber]]"></oj-bind-text></td><td><oj-bind-text value="[[row.item.data.Email]]"></oj-bind-text></td><td class="oj-sm-padding-0-vertical"><oj-button display="icons" chroming="borderless" data-oj-clickthrough="disabled"><span slot="startIcon" class="oj-ux-ico-edit"></span>Edit</oj-button></td><!-- /ko --><!-- ko if: row.mode === "edit" --><oj-bind-if test='[[ row.mode === "edit" ]]'><td colspan="5" class="oj-form-control-default oj-sm-padding-2x oj-table-data-cell-padding"><oj-validation-group id="validate-edit-form"><oj-form-layout id="ofl1" max-columns="4" direction="row"><oj-input-text id="it1" label-hint="FirstName" value="{{ $variables.rowData.FirstName }}"class="editable" required="true"></oj-input-text><oj-input-text id="it2" label-hint="LastName" value="{{$variables.rowData.LastName}}"></oj-input-text><oj-input-text id="it3" label-hint="PhoneNumber" value="{{$variables.rowData.PhoneNumber}}"></oj-input-text><oj-input-text id="it4" label-hint="Email" value="{{$variables.rowData.Email}}"></oj-input-text></oj-form-layout></oj-validation-group><oj-button id="cancel" chroming="borderless" data-oj-clickthrough="disabled">Cancel</oj-button><oj-button id="update" chroming="outlined" data-oj-clickthrough="disabled">Apply</oj-button></td><!-- /ko --></tr></template>
- After implementing the above templte the ui should look like below
- Create an ojAction on edit row button and assign shown value to editRow variable
- Now run the application, on click of edit row button an editable form will open
- Now lets pass value to this form, for this we will have to create a ojBeforeRowEdit event and assign value to our custom rowData object
- Now let’s rerun the application, this time we should see data populate in the form on click of edit button
Comments
Post a Comment