How to match field names on DataCollection for combo editor?

Hello!
I use DataTable UI widget with combo column. The data for this column comes from a get request from the API service. But they have the following form:

[{ Id: 1, Name: "First"}, {Id: 2, Name: "Second" }]

Most likely, the widget expects id (with a small letter) and value instead of “Id” and “Name”. How do I specify that id is “Id” and value is “Name”?

let catData = new webix.DataCollection({
        url: "/api/category",        
    });

view: "datatable",
        columns: [
            { id: "CategoryId", editor: "combo", options: catData, header: "Category", width: 200 },
        ],

It possible to reconfigure combo, so it will use Name or any other field(s) for the label, but the record ID must be defined as “id”, there is no workaround for that.

In your case the best strategy will be to translate data after loading from the remote API

let catData = new webix.DataCollection({
        data:  webix.ajax("/api/category").then(raw => 
              raw.json().map(a => ({ id: a.Id, value: a.Name }))
        ),        
});
1 Like