I have a dropdownlist in a grid. When I put a row in edit mode and change the selected value of the ddl, the data sent to my update procedure is the value field (i.e. 1, 5, 7). What I want to send is the text field (i.e. Apples, Oranages, Bananas).
How can I ensure the text value of the dropdownlist is being sent to my update method?
If I don't change the selection it works like I want (meaning the text value is sent to my update procedure). Only when I change the selected value the parameter value sent is the value field.
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <div id="grid"> </div> <script type="text/javascript"> $(document).ready(function () { $("#grid").kendoGrid({ //height: 260, toolbar: ["create"], columns: [ "DepartmentID", { field: "FRSAccountNumber", title: "FRS Account No", sortable: true, filterable: true }, { field: "DepartmentName", title: "Dept Name", sortable: true, filterable: true }, { field: "CollegeName", width: "150px", editor: categoryDropDownEditor }, { field: "SubjectArea", title: "Subj Area", sortable: true, filterable: true }, { command: ["edit", "destroy"], title: " ", width: "210px", filterable: false } ], editable: "inline", dataSource: { //batch: true, pageSize: 10, schema: { data: function (data) { return data.d || []; }, type: "json", total: "d.length", model: { id: "DepartmentID", fields: { DepartmentID: { type: "number" }, FRSAccountNumber: { type: "string" }, DepartmentName: { type: "string" }, CollegeName: "CollegeName", SubjectArea: { type: "string" } }//fields }//model }, //schema transport: { read: { url: "Web/KendoDS.asmx/ReadDepartments", contentType: "application/json; charset=utf-8", type: "POST" }, //read update: { url: "Web/KendoDS.asmx/Update", contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON type: "POST" //use HTTP POST request as the default GET is not allowed for ASMX }, parameterMap: function (data, operation) { if (operation != "read") { return JSON.stringify({ dept: data }); } } }//transport }, //dataSource pageable: true }); var categoryDataSource = new kendo.data.DataSource({ transport: { read: { url: "Web/KendoDS.asmx/GetColleges", contentType: "application/json; charset=utf-8", type: "POST" } }, schema: { data: "d" } }); function categoryDropDownEditor(container, options) { $('<input data-text-field="CollegeName" data-value-field="Ranking" data-bind="value:' + options.field + '"/>') .appendTo(container) .kendoDropDownList({ autoBind: false, dataSource: categoryDataSource }); } }); </script></asp:Content><select data-role="dropdownlist" data-bind="source: type, value: expenseType"> <span data-text-field="name" data-value-field="value" ></select><select data-role="dropdownlist" data-bind="source: type, value: expenseType" data-text-field="name" data-value-field="value" ></select>I am new to kendoUI and facing a few issues
1. not able to get the grid reference. (for changing the grid properties)
var grd = $("#grid").data("kendoGrid"); // Not working. grd is shown as undefined.
2. DataBound event is not recognized.
Please let me know what i am I missing here.
Please find my code below
<div class="k-content">
@(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =>
{
columns.Bound(company => company.Id).Hidden();
columns.Bound(company => company.CompanyName).Sortable(true).Width(120);
columns.Bound(company => company.Email).Sortable(true).Width(150);
columns.Bound(company => company.CompanyAddressAddress1).Width(120);
columns.Bound(company => company.CompanyAddressAddress2).Width(120);
columns.Bound(company => company.CompanyAddressCity);
columns.Bound(company => company.CompanyAddressStateAbbreviation).Width(80);
columns.Bound(company => company.CompanyAddressZip).Width(100);
columns.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(180);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("CompanyCreate")
.Window(window => window.Title("Company Profile").Name("CompanyEdit"))
)
.Groupable()
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Events(
events =>
{
//events.Change("");
events.Error("error_handler");
events.DataBound("reload_grid");//gives error
}
)
.Model(model => model.Id(company => company.Id))
.Create(update => update.Action("CompanyCreate", "Company", new { act = "Create" }))
.Update(update => update.Action("CompanyUpdate", "Company", new { act = "Update" }))
.Destroy(update => update.Action("CompanyDestroy", "Company"))
.Read(read => read.Action("CompanyRead", "Company"))
)
)
<script type="text/javascript">
// get a reference to the grid
var grd = $("#grid").data("kendoGrid"); // Not working. grd is shown as undefined.
$(".k-grid-add").on("click", function (e) {
var insertMode = e.model.isNew(); //gives error
var window = e.container.data("kendoWindow");//gives error
e.container.kendoWindow("title", "Add new record");//gives error.
});
function reload_grid(e) {
//alert("reload");
}
</script>.


<div>${content}</div>