Datatable Combo Bug

Hi,

I want to change a value of my datatable cell by selecting values from Combo-Box.
The cell is empty (undefined) and I now want to give it a value.
But that’s not working: TypeError: Cannot read property ‘id’ of undefined.

Is there a workaround? I do not want to fill all cells with placeholders like N/A in case of undefined.

Hi,

Can you please provide a sample where the issue can be tested? As I understand the use-case, it works: http://webix.com/snippet/58f6aff1

Hmm I’ll try…
Problem is here: webix_debug Line 7961:

setMasterValue:function(data, refresh){
	var text = data.id ? this.getItemText(data.id) : (data.text||data.value);

So… you work with collection-Tag. I always used the options-Tag instead.
Could you please tell me the difference?
Is options deprecated?

I fixed it… Didn’t put a ID to my options-Array.

But now I’ve got a new problem…
After $$(grid).getItem(id), I just receive the IDs from combo-inputs - not the values?

So… instead of “THE Shawshank Redemption”, I get a 1

It’s a normal behavior. In such use-cases as yours, we usually suggest setting similarid/value attributes in the collection.

Historically, bothoptions andcollection feature the same functionality.

Please check: http://webix.com/snippet/b2f0305a

How it works: the collection is an independent data storage for the particular column, which contains items withid/value attributes. It is bound with original data through the IDs of items. I.e.

// main dataset:
{ id:1, collectionColumn:3, ... }

// collection/options array:
{ id:3, value:"Some value" }

will render “Some value” in the corresponding cell (row:1, column:‘collectionColumn’).

Ok, before I didn’t use an ID. But now, I’m using a ID-Value Pair and don’t receive the value anymore but the ID…How can I get back the value? The ID is useless for me

Ahh… you mean ID = VALUE? ID and VALUE as String?

Do I really need to do the following code, to get my value?! :smiley:

console.log(data[state.value-1].value)

http://webix.com/snippet/431afcbc

you mean ID = VALUE? ID and VALUE as String?

Exactly. In such case, the data in the main dataset will match the options. Besides, if you just set an array of string options, such collection will be created automatically:

http://webix.com/snippet/20cf2c79

But if you really want to refer to the string value using the options, you can get it from the collection, as it is a DataStore which is supporting all needed methods:

  on:{
    onAfterEditStop:function(state, editor){
      var columnStorage = this.getColumnConfig(editor.column).collection;
      console.log(columnStorage.getItem(state.value).value)        
    }
  }