I have an MVVM application using Kendo Grid, and I want to display hierarchy (nested grid). I am trying to replicate this example but I am not able to display the hierarchy data. How can I get the hierarchy records to display?
cshtml code:
<
div
id
=
"custOrderGrid"
data-role
=
"grid"
data-resizable
=
"false"
data-navigatable
=
"true"
data-editable
=
"true"
data-pageable
=
"false"
data-scrollable
=
"true"
onscroll
=
"true"
data-detail-template
=
"child-template"
data-columns="[
{ 'field': 'OrderID', 'title': '<b>Order #', 'width': 65 },
{ 'field': 'LineNo', 'title': '<
b
>Line Number', 'width': 65 },
{ 'field': 'ItemNo', 'title': '<
b
>Item Number', 'width': 65 },
{ 'field': 'Desc', 'title': '<
b
>Description', 'width': 150 }
]"
data-bind="source: orderSearchResults"
style="height: 55%">
</
div
>
<
script
id
=
"child-template"
type
=
"text/x-kendo-template"
>
<
div
data-role
=
"grid"
data-bind
=
"source: obj2"
data-columns="[
{ field: 'name' },
{ field: 'oid' }
]"></
div
>
</
script
>
typescript code:
orderSearchResults =
new
kendo.data.DataSource({
schema: {
model: {
id:
"OrderID"
,
fields: {
LineNo: { type:
"string"
},
ItemNo: { type:
"string"
},
Description: { type:
"string"
}
}
}
},
data: [
{
OrderID:
"L44ZX4"
, LineNo:
"15"
, ItemNo:
"*X1WCJH"
, Description:
"CDF9X2XSB"
,
obj2: [{
name:
'a1'
,
oid: 1
},
{
name:
'b1'
,
oid: 2
},
{
name:
'c1'
,
oid: 3
}]
}
]
});
I don't see an error messages. How can I display the hierarchy records? See image file attached.
In Internet Explorer 10, while we are add one row using "Add" button, the row will be added on the last position in the grid instead of top of the grid.
Hello Telerik team
--------------- Problem ---------------
I'm using Kendo template to show a Grid. Data bind to this Grid retrieves from 3 tables, each table in Database map to a class in source.
I build my grid using Kendo template, and bind to div using Kendo.
html
<div id="GridQuestion" data-bind="..."></div>
<
script
type
=
"text/html"
id
=
"temp-grid"
>
<
div
data-bind
=
"..."
>
.... grid structure
</
div
>
</
script
>
kendo.bind($('#GridQuestion'), questionViewModel);
Grid shows data as this: List groupQuestionSet, each groupQuestionSet contains many QuestionSet, each QuestionSet contains many Question.
This is Grid screen in browser:
This is Table Relationship.
This is storeprocedure, SQL query :
SELECT
GroupQuestionSet.Id
AS
'GroupQuestionSetId'
, GroupQuestionSet.GroupQuestionSetName, QuestionSet.Id
AS
'QuestionSetId'
, QuestionSet.QuestionSetName, Question.Id
as
'QuestionId'
, Question.QuestionContent
FROM
GroupQuestionSet
INNER
JOIN
QuestionSet
ON
GroupQuestionSet.Id = QuestionSet.GroupQuestionSetId
INNER
JOIN
Question
on
Question.QuestionSetId = QuestionSet.Id
This is JSON test data :
function
initTestData() {
//This is data from GroupQuestionSetTable in database
var
GroupQuestionSetTable = [
{
"Id"
: 1,
"GroupQuestionSetName"
:
"GroupQuestionSet 1"
},
{
"Id"
: 2,
"GroupQuestionSetName"
:
"GroupQuestionSet 2"
},
{
"Id"
: 3,
"GroupQuestionSetName"
:
"GroupQuestionSet 3"
}
];
//This is data from QuestionSetTable in database
//GroupQuestionSetId if foreign key link to Id column of GroupQuestionSetTable
var
QuestionSetTable = [
{
"Id"
: 1,
"GroupQuestionSetId"
: 1,
"QuestionSetName"
:
"QuestionSet 1"
},
{
"Id"
: 2,
"GroupQuestionSetId"
: 1,
"QuestionSetName"
:
"QuestionSet 2"
},
{
"Id"
: 3,
"GroupQuestionSetId"
: 1,
"QuestionSetName"
:
"QuestionSet 3"
},
{
"Id"
: 4,
"GroupQuestionSetId"
: 2,
"QuestionSetName"
:
"QuestionSet 4"
}
];
//This is data from SubQuestionTable in database
//QuestionSetId if foreign key link to Id column of QuestionSetTable
var
QuestionTable = [
{
"Id"
: 1,
"QuestionSetId"
: 1,
"QuestionContent"
:
"QuestionContent 1"
},
{
"Id"
: 2,
"QuestionSetId"
: 1,
"QuestionContent"
:
"QuestionContent 2"
},
{
"Id"
: 3,
"QuestionSetId"
: 1,
"QuestionContent"
:
"QuestionContent 3"
},
{
"Id"
: 4,
"QuestionSetId"
: 2,
"QuestionContent"
:
"QuestionContent 4"
}
];
}
------------------------ need ------------------------
When I create, update, delete Question inside QuestionSet (or GroupQuestionSet or QuestionSet) Grid only interact with Database and only reload that row. The same as when we use Kendo grid with create, read, update, delete
------------------------ My curent solution ------------------------
When insert, update, del: Browser rebind all grid. -> it will slow if we have large data.
------------------------ My temporary solution ------------------------
I have read this topic http://stackoverflow.com/questions/16097878/kendo-ui-unable-to-bind-data-to-list-view-using-mvvm but I don't understand.
My temporary solution is :
Source:
Contruct a Temp object the same as result table from above query-->Load Kendo grid using that list of Temp object and use Kendo grid with create, read, update, delete -> In create, read, update, delete I will write code to create, read, update, delete to only GroupQuestionSet or QuestionSet or Question
I still looking for some other solutions.
Thank you.
var
Manufacturer = kendo.data.Node.extend({
//...
});
var
Car = kendo.data.Node.extend({
//...
});
var
Part = kendo.data.Node.extend({
//...
});