Dear Community,
We are evaluating KendoUI for our needs and here is one of the problem we have stuck on.
Problem Statement
We are trying to achieve almost similar to what is shown in demo http://demos.kendoui.com/web/grid/editing-custom.html.
Here is what we are doing.
We have a data source to fill the combo-box which will appear within the grid. It is basically a list of cities.
We also have main data source which contains lot more columns. Here you will observe that we have CityID as one of the fields.
In document.Ready function, we are preparing our data source (Please note CityName in fields section).
There is a div tag on page called grid.
Creating grid (Please note editor:cityDropDownEditor):
Here is the cityDropDownEditor function:
What do we want?
We want that when we click on the City column of the grid, dropdown should open up and when user changes the selection, it must reflect on the UI and as well as on my observable collection called viewModel.
But this is not happening at present. Our scenario is bit different from what is available in demo as there they are using CategoryName to bind both value and text fields of combo-box.
Please help as this is an urgent request and let me know if you need more details around this.
Regards,
Shiva
We are evaluating KendoUI for our needs and here is one of the problem we have stuck on.
Problem Statement
We are trying to achieve almost similar to what is shown in demo http://demos.kendoui.com/web/grid/editing-custom.html.
Here is what we are doing.
We have a data source to fill the combo-box which will appear within the grid. It is basically a list of cities.
var cityDataSource = [{ CityID: 1, CityName: 'Delhi' }, { CityID: 2, CityName: 'Noida'}]
We also have main data source which contains lot more columns. Here you will observe that we have CityID as one of the fields.
var viewModel = kendo.observable({
gridSource: [
{ FirstName: "Shiva", LastName: "Wahi", CityID: 2, Title: "Module Lead", BirthDate: "10/29/1984", Age: 27 },
{ FirstName: "Priya", LastName: "Srivastava", CityID: 1, Title: "Tech Lead", BirthDate: "08/19/1982", Age: 30 }
]
});
In document.Ready function, we are preparing our data source (Please note CityName in fields section).
$(document).ready(function () {
var dataSource = new kendo.data.DataSource({
pageSize: 30,
data: viewModel.gridSource,
autoSync: true,
schema: {
model: {
fields: {
FirstName: { type: "string" },
LastName: { type: "string" },
CityName: "CityName",
Title: { type: "string" },
BirthDate: { type: "date" },
Age: { type: "number" }
}
}
}
});
There is a div tag on page called grid.
<
div
id
=
"grid"
/>
Creating grid (Please note editor:cityDropDownEditor):
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
editable: true,
height: 260,
toolbar: ["create"],
columns: [
{
field: "FirstName",
title: "First Name",
width: 100
},
{
field: "LastName",
title: "Last Name",
width: 100
},
{
field: "CityName",
title: "City",
width: 100,
editor: cityDropDownEditor
},
{
field: "Title",
width: 75
},
{
field: "BirthDate",
title: "Birth Date",
width: 75,
template: '#= kendo.toString(BirthDate,"MM/dd/yyyy") #'
},
{
field: "Age",
width: 50
}
]
});
});
Here is the cityDropDownEditor function:
function cityDropDownEditor(container, options) {
$('<
input
data-text-field
=
"CityName"
data-value-field
=
"CityName"
data-bind
=
"value:' + options.field + '"
/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataSource: cityDataSource
});
}
What do we want?
We want that when we click on the City column of the grid, dropdown should open up and when user changes the selection, it must reflect on the UI and as well as on my observable collection called viewModel.
But this is not happening at present. Our scenario is bit different from what is available in demo as there they are using CategoryName to bind both value and text fields of combo-box.
Please help as this is an urgent request and let me know if you need more details around this.
Regards,
Shiva