Environment:
VS2010 - MVC4 Web Project
Server 2008 R2
IE 8 / FF 10
Telerik UI for ASP.NET MVC 2014.1 318
jQuery 1.9.0
I am not able to get a reference using the element.data("kendoGrid") syntax. Every time I hit that code, my variable is undefined.
Can someone please point me to what I'm missing?
Html:
01.
<
div
class
=
"col-md-2"
>
02.
<
div
class
=
"panel panel-default"
>
03.
<
div
class
=
"panel-heading"
>Line of Business</
div
>
04.
<
div
class
=
"panel-body"
id
=
"lobnav"
></
div
>
05.
</
div
>
06.
<
div
class
=
"panel panel-default"
>
07.
<
div
class
=
"panel-heading"
>Application</
div
>
08.
<
div
class
=
"panel-body"
id
=
"lobapp"
></
div
>
09.
</
div
>
10.
<
div
class
=
"panel panel-default"
>
11.
<
div
class
=
"panel-heading"
>Filter</
div
>
12.
<
div
class
=
"panel-body"
id
=
"jobfilter"
></
div
>
13.
</
div
>
14.
</
div
>
15.
<
div
class
=
"col-md-10"
>
16.
<
div
id
=
"jobsgrid"
></
div
>
17.
</
div
>
Code:
001.
$(document).ready(
function
() {
002.
function
resizeGrid() {
003.
var
gridElement = $(
"#jobsgrid"
),
004.
dataArea = gridElement.find(
".k-grid-content"
),
005.
gridHeight = gridElement.innerHeight(),
006.
otherElements = gridElement.children().not(
".k-grid-content"
),
007.
otherElementsHeight = 0;
008.
otherElements.each(
function
() {
009.
otherElementsHeight += $(
this
).outerHeight();
010.
});
011.
dataArea.height(gridHeight - otherElementsHeight);
012.
};
013.
014.
function
loadApplications(arg) {
015.
$(
"#lobapp"
).kendoListView({
016.
selectable:
"single"
,
017.
change:
function
(e) {
018.
loadJobs(arg,
false
);
019.
},
020.
template:
"<div>${Name}</div>"
,
021.
dataSource: {
022.
transport: {
023.
read: {
024.
url:
"/api/App"
025.
},
026.
parameterMap:
function
(options, type) {
027.
return
{
'id'
: arg };
028.
}
029.
}
030.
}
031.
});
032.
};
033.
034.
function
filterJobs(arg) {
035.
var
jgrid = $(
"#jobsgrid"
).data(
"kendoGrid"
);
036.
if
(arg !== 1) {
037.
jgrid.dataSource.filter({
038.
field:
"Status"
, operator:
"eq"
, value: arg
039.
});
040.
}
else
{
041.
jgrid.dataSource.filter({});
042.
}
043.
};
044.
045.
$(window).resize(
function
() {
046.
resizeGrid();
047.
});
048.
049.
$(
"#jobfilter"
).kendoListView({
050.
selectable:
"single"
,
051.
template:
"<div id='filter-${Id}'>${Name}</div>"
,
052.
dataSource: {
053.
transport: {
054.
read: {
055.
url:
"/api/Theme"
056.
}
057.
}
058.
},
059.
change:
function
(e) {
060.
var
itm =
this
.select().index(), dataItm =
this
.dataSource.view()[itm];
061.
filterJobs(dataItm.id);
062.
}
063.
});
064.
065.
$(
"#lobnav"
).kendoTreeView({
066.
select:
function
(e) {
067.
var
tree =
this
, src = tree.dataItem(e.node);
068.
loadApplications(src.id);
069.
if
(src.hasChildren) {
070.
loadJobs(src.id,
true
);
071.
}
else
{
072.
loadJobs(src.id,
false
);
073.
}
074.
},
075.
dataSource: {
076.
transport: {
077.
read: {
078.
url:
"/api/Lob"
079.
}
080.
},
081.
schema: {
082.
model: {
083.
id:
"Id"
,
084.
hasChildren:
"HasChildren"
085.
}
086.
}
087.
},
088.
loadOnDemand:
false
,
089.
dataTextField:
"Name"
090.
});
091.
092.
function
loadJobs(arg, parent) {
093.
$(
"#jobsgrid"
).kendoGrid({
094.
columns: [
095.
{
096.
field:
"owner"
,
097.
title:
"Application"
,
098.
width:
"5%"
099.
},
100.
{
101.
field:
"name"
,
102.
title:
"Process Name"
,
103.
width:
"18%"
104.
},
105.
{
106.
field:
"prcnt"
,
107.
title:
"Percent Complete"
,
108.
template:
"<div class='progress'></div>"
,
109.
width:
"30%"
110.
},
111.
{
112.
field:
"avgtime"
,
113.
title:
"Average Time"
,
114.
format:
"{0:hh:mm:ss}"
,
115.
width:
"12%"
116.
},
117.
{
118.
field:
"elapsed"
,
119.
title:
"Elapsed Time"
,
120.
format:
"{0:hh:mm:ss}"
,
121.
width:
"12%"
122.
},
123.
{
124.
field:
"dproc"
,
125.
title:
"Dependent Process"
,
126.
width:
"5%"
127.
},
128.
{
129.
field:
"status"
,
130.
title:
"Status"
131.
}
132.
],
133.
sortable: {
134.
mode:
"single"
,
135.
allowUnsort:
true
136.
},
137.
pageable:
true
,
138.
scrollable:
false
,
139.
resizable:
true
,
140.
dataSource: {
141.
transport: {
142.
read: {
143.
url:
"/api/Process?id="
+ arg +
"&parent="
+ parent
144.
}
145.
},
146.
schema: {
147.
data:
"Data"
,
148.
total:
"Count"
,
149.
model: { id:
"Id"
}
150.
},
151.
pageSize: 15,
152.
serverPaging:
true
,
153.
serverFiltering:
true
154.
},
155.
dataBound:
function
(e) {
156.
var
grid =
this
;
157.
$(
".progress"
).each(
function
() {
158.
var
row = $(
this
).closest(
"tr"
);
159.
var
model = grid.dataItem(row);
160.
if
(model.prcnt <= 100) {
161.
$(
this
).kendoProgressBar({
162.
value: model.prcnt,
163.
type:
"percent"
164.
});
165.
}
else
{
166.
$(
this
).kendoProgressBar({
167.
value: model.prcnt,
168.
type:
"percent"
169.
}).html(
"<span class='k-progress-status-wrap'>"
+
170.
"<span class='k-progress-status'>Overtime</span></span>"
+
171.
"<div class='k-state-selected k-complete' style='width: 100%;'>"
+
172.
"<span class='k-progress-status-wrap overtime' style='width: 100%;'>"
+
173.
"<span class='k-progress-status overtime'>Overtime</span></span></div>"
);
174.
}
175.
});
176.
}
177.
});
178.
};
179.
});