Handsontable: Assigning a default value to my column cells and making datatype validation

Created on 4 Feb 2013  路  3Comments  路  Source: handsontable/handsontable

Hi Guys,

iam wondering how we can assign a default value to a column cells.
Also, how we can make data type validation

thank peers.

Question

Most helpful comment

This to me is hardly acceptable. Googling around, there are several use cases for supplying default values. While I appreciate the flexibility this method allows, it seems extreme to have to write a custom render method and custom beforeChange method that parses all this out just to produce new rows with default data.

I envision a Handsontable property that lets you assign a simple JSON object with the property name and default value. I will make a feature request.

All 3 comments

Have you seen this example? Does it answer your qwuestion maybe? http://handsontable.com/demo/prepopulate.html

This to me is hardly acceptable. Googling around, there are several use cases for supplying default values. While I appreciate the flexibility this method allows, it seems extreme to have to write a custom render method and custom beforeChange method that parses all this out just to produce new rows with default data.

I envision a Handsontable property that lets you assign a simple JSON object with the property name and default value. I will make a feature request.

In case someone stumbles over this old thread, like I did:
The best solution to achieve default values for new rows is to use the dataSchema configuration option:

new Handsontable(container, {
  data: []
  colHeaders: ['ID', 'My Text'],
  columns: [
    {data: 'id'},
    {data: 'myText'}
  ],
  dataSchema: {id: null, myText: 'my default text'},      // <----------
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlrosenberg24 picture jlrosenberg24  路  3Comments

finmt picture finmt  路  3Comments

wszymanski picture wszymanski  路  3Comments

astegmaier picture astegmaier  路  3Comments

jeremy-smith-maco picture jeremy-smith-maco  路  3Comments