2.0.1 • Published 6 years ago

detail_row_editor v2.0.1

Weekly downloads
18
License
-
Repository
-
Last release
6 years ago

Vuetable-2 Detail row editor

Details row editor meant for Vuetable-2

Example image

Usage

Inside template

<vuetable ref="vuetable"
    ...
    detail-row-component="detail-row"
    ...
  ></vuetable>

Inside script

import DetailRowEditor from 'detail-row-editor/src/components/DetailRowEditor'
Vue.component('detail-row', DetailRowEditor);

Properties

Due to the fact that vuetable passes only two props to it's details row (rowData and rowIndex) any other properties needs to be passed this way

Vue.prototype.detailRowOptions = {
  onSave: (data) => {
  return new Promise((resolve) =>  {
      // Do stuff using data. Unless autoHideOnSaveOrCancel is set to false, the details row will be hidden when this promise is resolved
      resolve();
    });
  };
};
NameTypeDefault valueDescription
autoRowUpdateAfterChangebooleantrueIf set to true, the parent row will be updated on every change
autoRowUpdateAfterSavebooleantrueIf set to true, the parent row will be updated after save
autoHideOnSaveOrCancelbooleantrueIf set to true, the details row will be automatically hidden after save / cancel
onSavefunctionnullFunction which will be called on save. It takes data as an argument and it is required to return a Promise object. See example code for tips on error handling.
onCancelfunctionnullFunction which will be called on cancel. It is required to return a Promise object.
headerComponentnullHeader component
footerComponentnullCustom footer component
showFooterbooleantrueWhenever footer (buttons) should be hidden
buttonClassesString''Classes which will be added to save / cancel buttons (separated by space)
boldLabelbooleanfalseWhenever field title should be bolded
fieldsarray[]Must be set in order for editor to work

Field properties

Fields also should have certain properties specified in order to be editable.

NameTypeDefault valueDescription
editablebooleanfalseImportant! You must set this value to true in order for it to be editable
typeStringtextAny valid HTML input type will do (note that no additional attributes will be added, so there is no point in specifying a radio type for example)
detailRowComponentComponentnullCustom field component. See example for more detailed informations

Example code

# clone project
git clone https://github.com/kamilbeben/detail-row-editor.git
cd detail-row-editor

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev