How to pass key value pair to handsontable dropdown?

6,337 views
Skip to first unread message

chan...@gmail.com

unread,
Aug 29, 2014, 5:57:46 AM8/29/14
to handso...@googlegroups.com
Hi is there any way to pass keyvalue pair to handsontable dropdown.

have id,Name display the name in Ui and store the id in Database.


any sample app is great help.

trebuchetty

unread,
Aug 29, 2014, 10:26:40 AM8/29/14
to handso...@googlegroups.com, chan...@gmail.com
There's no way to do this with the predefined set of editors.
I've made a Select2 editor for handsontable that you may find useful: https://github.com/trebuchetty/Handsontable-select2-editor

Other than that, you can extend one of the existing editors to do whatever you need: 

Hope that helps,

chan...@gmail.com

unread,
Aug 29, 2014, 1:02:56 PM8/29/14
to handso...@googlegroups.com, chan...@gmail.com
HI,
Could you have any sample how to use this selectEditor i am trying to use this but not able to if you have any sample html page it is really helps me alot

Thanks in advance.

chan...@gmail.com

unread,
Aug 31, 2014, 10:37:04 PM8/31/14
to handso...@googlegroups.com, chan...@gmail.com
HI,
I checked your sample2 editor it is displaying as text area and disabling all dropdowns.Let me know is there any specific configuration required.
Regards,
Chandra

trebuchetty

unread,
Sep 3, 2014, 11:22:33 PM9/3/14
to handso...@googlegroups.com, chan...@gmail.com
I've just added some fixes to the editor to bring it up to my production code.
As for it's use, I have something like this in my columns object for handsontable:
{
    data: 'ManufacturerPartNo',
    renderer: itemStatusAutocompleteRenderer,
    editor: 'select2',
    select2Options: this.select2ItemsListOptions('ManufacturerPartNo', this.model.get('CompanyName'))
},

The select2Options is just an options object that you would use to build any select2 dropdown. At the very least you'll need a data property and a query property. Go to Select2's documentation to figure out what you'll need for your specific use. Also, make sure you include the select2.js code in your build (obviously).

Hope that helps.

Luke

unread,
Oct 3, 2014, 4:50:57 PM10/3/14
to handso...@googlegroups.com
Hi Trebuchetty,

I'm using your excellent handsontable select2 editor, but when I select an option, the id value, not the text value is displayed in the cell. I have tried to write a custom renderer for this, but how do I make sure it displays the text, but still submits the id value. Earlier in this thread, you implied that the select2 editor would allow for that somehow.

Thanks,

Luke.

trebuchetty

unread,
Oct 6, 2014, 5:08:06 PM10/6/14
to handso...@googlegroups.com
The Select2 editor does allow for that. It's all in how you setup the select2 editor with the initialization options. Go to the select2 website to see all the available options. At the very least, the data object for the select2 dropdown should contain an "id" and "text" field so that what you see and what you actual select are correct.

madhu....@gmail.com

unread,
Mar 24, 2015, 5:14:34 PM3/24/15
to handso...@googlegroups.com
I am running into a similar issue. I am using select2-editor and it is displaying the id instead of the value. Also, clicking on the row is not aligning the select2 dropdown. Here is the jsfiddle: http://jsfiddle.net/mpusarla/sqoyds31/2/

Can you let me know if I am missing anything?

Thanks,
Madhu.

paul....@gmail.com

unread,
Feb 17, 2017, 6:32:33 PM2/17/17
to Handsontable, chan...@gmail.com

jExcel is aan alternative jquery plugin for handsontable. http://bossanova.uk/jexcel/working-with-dropdowns

Reply all
Reply to author
Forward
0 new messages