If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Pro Tip
SelectCell treats all option values as strings by default, if you need to persist a different type of values into your model, you should extend SelectCell to provide your own formatter.
See the JSDoc for the various Cell classes for details on what you can configure using this method.
Custom Cell
If the built-in and extension cell classes are not enough for you, you may choose to create your own cell class and supply it to a column definition.
If your custom cell will still use a <input type="text" /> like the predefined ones for editing, you may choose to subclass Cell or one of the predefined classes and simply define a className and a formatter. In fact, most of the core cell classes are done this way.// This is how StringCell is defined.
Backgrid.StringCell = Backgrid.Cell.extend({
// Cell default class names are the lower-cased and dasherized
// form of the the cell class names by convention.
className: "string-cell"
formatter: Backgrid.StringFormatter
});

If your cell class will render differently in display mode, you may simply override Cell#render() in your subclass.Custom CellEditor

Advanced Usage

Some cell types, like the TextCell extension, may only make sense if the editor is rendered in a modal dialog or a form element in a different part of the page. In that case the default InputCellEditor, which renders a <input type="text" />, will not be suitable and a new CellEditor must be defined.

A custom cell editor should subclass CellEditor as it defines a number of required parameters in its initializer and clean up operations that are necessary for most cell editors. When a cell class enters edit mode, a new editor instance is constructed by given it the required parameters, and then a Backbone event backgrid:edit is fired from the cell instance itself. A custom cell class can act on this event to do anything before the cell editor is rendered.

Once the cell has entered edit mode, a Backbone event backgrid:editing is fired. A custom cell class can then act on it to do anything after the cell editor has been rendered, e.g. placing the focus inside the editor.

During editing, if an error is encountered (see the formatter protocol below), a cell editor should fire a Backbone event backgrid:error so that listeners—usually a cell instance—can respond appropriately. When editing is done, a cell editor should fire a Backbone backgrid:edited event. A cell should be listening to this event so it can remove its editor and re-render itsef in display mode.

Truely Advanced Hacking

At the most basic level, Cells and CellEditors are simply Backbone.View classes that are guaranteed to be given a number of parameters when constructed by Row. You can use any Backbone.View as your Cell and CellEditor.

As you have said "If your cell class will render differently in display mode, you may simply override Cell#render() in your subclass."
Where I should add this Cell#render(). Should I have this Cell#render in model or in the view.
Still have several issues about this override Cell#render().
Thanks
K

Originally Posted by softqubetechno

Hello friend, as per your query i searched and get this answer, hope this will help you with your problem;

Pro Tip
SelectCell treats all option values as strings by default, if you need to persist a different type of values into your model, you should extend SelectCell to provide your own formatter.
See the JSDoc for the various Cell classes for details on what you can configure using this method.
Custom Cell
If the built-in and extension cell classes are not enough for you, you may choose to create your own cell class and supply it to a column definition.
If your custom cell will still use a <input type="text" /> like the predefined ones for editing, you may choose to subclass Cell or one of the predefined classes and simply define a className and a formatter. In fact, most of the core cell classes are done this way.// This is how StringCell is defined.
Backgrid.StringCell = Backgrid.Cell.extend({
// Cell default class names are the lower-cased and dasherized
// form of the the cell class names by convention.
className: "string-cell"
formatter: Backgrid.StringFormatter
});

If your cell class will render differently in display mode, you may simply override Cell#render() in your subclass.Custom CellEditor

Advanced Usage

Some cell types, like the TextCell extension, may only make sense if the editor is rendered in a modal dialog or a form element in a different part of the page. In that case the default InputCellEditor, which renders a <input type="text" />, will not be suitable and a new CellEditor must be defined.

A custom cell editor should subclass CellEditor as it defines a number of required parameters in its initializer and clean up operations that are necessary for most cell editors. When a cell class enters edit mode, a new editor instance is constructed by given it the required parameters, and then a Backbone event backgrid:edit is fired from the cell instance itself. A custom cell class can act on this event to do anything before the cell editor is rendered.

Once the cell has entered edit mode, a Backbone event backgrid:editing is fired. A custom cell class can then act on it to do anything after the cell editor has been rendered, e.g. placing the focus inside the editor.

During editing, if an error is encountered (see the formatter protocol below), a cell editor should fire a Backbone event backgrid:error so that listeners—usually a cell instance—can respond appropriately. When editing is done, a cell editor should fire a Backbone backgrid:edited event. A cell should be listening to this event so it can remove its editor and re-render itsef in display mode.

Truely Advanced Hacking

At the most basic level, Cells and CellEditors are simply Backbone.View classes that are guaranteed to be given a number of parameters when constructed by Row. You can use any Backbone.View as your Cell and CellEditor.