Simple Column HTML

"Simple column HTML" is where we let the grid do the most of the work for us when it comes to adding css classes/markup. We only add <v-grid-col> inside the <v-grid> element with some attributes. Lets look on a small sample to get started.

First we will need to define the required variable in our class : *v-collection

//page.js

export class Page {


  //collection to display
  myCollection = [
    {index:1, name:"Leif"}, 
    {index:2, name:"Per"},
    {index:3, name:"John"},
    ];

}

For the HTML we :

  • bind the variables we just created.

  • set row & header height.

  • add the v-grid-col with a col-field attribute for the field in collection we want.

To add filters/sorting to grid we will need to add more attributes.

This will then produced the grid you see in the picture below Some features are enabled be default when using "simple column HTML"

  • Drag drop headers

  • re-size of columns

  • Observing changes on from/to grid/current entity.

sample grid

All attributes we have available :

  • col-width

  • col-type

  • col-field (REQUIRED)

  • col-sort

  • col-header-name

  • col-filter

  • col-filter-top

  • col-css

  • col-add-row-attributes

  • col-add-filter-attributes

More details about the attibutes:

col-width:

  • default is 100

  • sets the width of the column

col-type:

  • default is "text"

  • options are "selection", "checkbox" or "image"

col-field: (REQUIRED)

  • field/property of the data from collection

col-sort:

  • default is ""

  • field name you want to do sorting on

col-header-name:

  • default is col-field where first letter is set to uppercase

col-filter:

  • see v-filter in chapter 04 for more details

col-filter-top:

  • default is false

  • use false/true to set filter above/under label in header

col-css:

  • css you want to add, usefull with on-row draw event for setting colors based on values

col-add-row-attributes:

  • here you can put whatever you want and it gets added to row column, useful for own custom attributes

col-add-filter-attributes:

  • here you can put whatever you want and it gets added header column, useful for own custom attributes

Last updated