I've been trying to get Keno Grid working in my app for a week now and I *finally* got to the point where the dataSource transport actually calls the controller action. However, I cannot seem to get anything moving forward from there.
I see have two problems right now.
1) All the controller action examples I've seen so far seem to expect the incoming data to have a related model on the server side. For example:
public
JsonResult Update()
{
var employees =
this
.DeserializeObject<IEnumerable<EmployeeDirectoryModel>>(
"models"
);
if
(employees !=
null
)
{
foreach
(var employee
in
employees)
{
EmployeeDirectoryRepository.Update(employee);
}
}
return
this
.Jsonp(employees);
}
However, I do not have something similar to EmployeeDirectoryModel (in the above example) to which I can deserialize the incoming data. The data being submitted from the client needs to be ultimately just be json which I will store in a completely unrelated model as a string.
public
class
ClientRow
{
public
Guid Id {
get
;
set
; }
public
Guid TableId {
get
;
set
; }
public
string
RowData {
get
;
set
; }
// json here
}
2) When trying to figure out a workaround for the above I was having troubles figuring out where (and in what form) the data being sent from the client is. I put a break point in the controller action and looked around in the context and could not find ANY data that would have been sent. So then I opened Fiddler and could not find the data anywhere in the request packet for the Update.
I'm assuming I have something misconfigured somewhere. Here is my entire function which draws the grid. What here is not configured properly so that the Update event would be triggered but no data would go over the wire?
var
gridName =
'#'
+controlId +
'-grid'
;
var
dataSource =
new
kendo.data.DataSource({
transport: {
read: {
url:
'/Data/Read/'
+ componentId,
dataType:
'json'
},
update: {
url:
'/Data/Update'
,
dataType:
'json'
},
destroy: {
url:
'/Data/Destroy'
,
dataType:
'json'
},
create: {
url:
'/Data/Create'
,
dataType:
'json'
},
parameterMap:
function
(options, operation) {
if
(operation !==
"read"
&& options.models) {
return
{ models: kendo.stringify(options.models) };
}
}
},
pageSize: 20,
schema: {
model: {
id:
"Id"
,
fields: {
"Id"
: {
"editable"
:
false
,
"nullable"
:
false
},
"Category"
: {
"validation"
: {
"required"
:
true
} },
"Product"
: {
"validation"
: {
"required"
:
true
} },
"Color"
: {
"validation"
: {
"required"
:
true
} },
"Cost"
: {
"type"
:
"number"
,
"validation"
: {
"required"
:
true
} },
"MSRP"
: {
"type"
:
"number"
,
"validation"
: {
"required"
:
true
} }
}
}
}
});
var
grid = $(gridName).kendoGrid({
dataSource: dataSource,
selectable:
true
,
groupable:
true
,
sortable:
true
,
editable:
"inline"
,
toolbar: [
"create"
,
"save"
,
"cancel"
],
columns: [
{ field:
"User"
, title:
"User"
},
{ field:
"Category"
, title:
"Category"
},
{ field:
"Product"
, title:
"Name"
},
{ field:
"Color"
, title:
"Color"
},
{ field:
"Cost"
, title:
"Cost"
, format:
"{0:c}"
},
{ field:
"MSRP"
, title:
"MSRP"
, format:
"{0:c}"
},
{ field:
"EditedOn"
, title:
"Edited On"
},
{ command: [
"edit"
,
"destroy"
] , title:
" "
}
]
});
Please note: in the example code above I clearly have a defined model, but this is just sample code. The model/columns are all derived dynamically from some other data and the json for the dataSource "fields" and the grid "columns" are generated on the fly. There is no way to know what the actual model will look like and therefore I cannot have a defined model to deserialize on the server side.