schema: {
errors:
function
(response) {
return
response.errors;
},
model: {
id:
"ItemID"
,
fields: {
"Subject"
: { type:
"string"
},
"StartDate"
: { type:
"date"
},
"EndDate"
: { type:
"date"
}
}
}
},
var
dataSource =
new
kendo.data.DataSource({
transport: {
create: {
url:
"/api/Prospects"
,
type:
"POST"
},
read:
"/api/Prospects"
,
update: {
url:
"/api/Prospects"
,
type:
"PUT"
},
destroy: {
url:
"/api/Prospects"
,
type:
"DELETE"
}
},
schema: {
model: {
id:
"ProspectId"
,
fields: {
ProspectId: {
editable:
false
,
nullable:
true
},
FirstName: { type:
"string"
},
LastName: { type:
"string"
},
EmailAddress: { type:
"string"
},
ProspectTypeId: { type:
"number"
},
ProspectStatusId: { type:
"number"
}
}
},
type:
"json"
}
});
I have a simple class that has a class as one of it's properties. I am trying to use the grid to both display the properties and allow in-line editing. If I don't use default values and I try to edit I get "Microsoft JScript runtime error: Syntax error, unrecognized expression: [data-container-for=Person.PersonId].
If I do use default values I get "Cannot serialize objects of type Person" when I load the page.
Help would be greatly appreciated since I haven't been able to find any information.
-Kerry
Here's the code
class User
{
int UserId;
string LoginName;
Person person;
}
class Person
{
int PersonId;
string FirstName;
string LastName;
string Email;
}
<%
= Html.Kendo().Grid<UserDto>()
.Name("UserListGrid")
.DataSource(ds => ds.Ajax()
.Update(update => update.Action("AjaxSaveUser", "User"))
.Destroy(destroy => destroy.Action("AjaxDeleteUser", "User"))
.Create(create => create.Action("AjaxInsertUser", "User"))
.Read(read => read.Action("List", "User"))
.Model(model => model.Id(m => m.UserId))
.Model(model => model.Field(m => m.UserId).Editable(false))
.Events(e => e.Error("grid_OnError"))
)
.Columns(col =>
{
col.Bound(us => us.UserId).Title("ID");
col.Command(us => us.Edit());
col.Bound(us => us.LoginName).Title("Login");
col.Bound(us => us.Person.PersonId).Hidden();
col.Bound(us => us.Person.LastName).Title("Last Name");
col.Bound(us => us.Person.FirstName).Title("First Name");
col.Bound(us => us.Person.Email).Title("Email");
col.Command(us => us.Destroy());
})
.ToolBar(commands => commands.Create().Text("Add User"))
.Editable(edit => edit.Mode(GridEditMode.InLine))
%>
Hello,
I'm trying to tweak my combo box for optimum performance but what I'm trying to do is either not possible or I do not know how to do it properly.
What I want to happen is this :
1. When my page loads I want it to load only the selected item. I'm setting my dataSource to autoBind false and creating an input with a single option which is the selectedValue that I return back from the server. Then on the open I'm selecting that initial selected value out of the returned results. The idea behind this is I want to display selectedValue but do not want load rest of results unless user accesses the dropdown.
2. When typing in the comboBox I want each request to be sent back to the server. Currently it seems the way I have it setup that initially grabs the data from the server but then it does not callback to server as I change my typed value but instead limits value based on values already returned. The purpose behind this is my comboBox may return hundreds, if not thousands of records and I do not want it loading the whole set.
$(
'body'
).ready(
function
() {
var
jqWidget = $(
"#myWidget"
);
var
selectedValue = 1;
var
remoteDataSource = { transport:
{
read:
{
dataType :
"jsonp"
,
url :
"http://localhost:8080/detail/000/q"
,
data :
{
retrieveValues :
"true"
,
widgetName :
"manufacturingLocation"
},
autoBind :
false
,
autoSync :
true
},
serverFiltering:
true
}
};
var
selectDropdownFunction =
function
( e )
{
selectInitialValue( jqWidget, selectedValue );
};
jqWidget.kendoComboBox( {
dataSource : remoteDataSource,
autoBind :
false
,
dataTextField:
"value"
,
dataValueField:
"id"
,
open: selectDropdownFunction,
filter:
"contains"
,
suggest:
true
,
index: 0,
delay: 800
} );
});
function
selectInitialValue( jqWidget, selectedValue )
{
jqWidget.data(
'kendoComboBox'
).value(selectedValue);
}