I have a Kendo grid that displays the Grid with Details being a Tab. The first tab basically renders a different partial view based on the Row's StatusID column. The "if" condition within the .Content() method of the tab item script in the template just does not work. The if condition is always false and falls into the “else” block. Is there a specific syntax to get the parent field's value to compare? I tried using the escape characters \\ before the pre-processor character #
Thanks!
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.Name).Groupable(false);
columns.Bound(p => p.StatusName).Width(100);
columns.Bound(p => p.Description).Title("Description").Width(150);
columns.Bound(p => p.City).Width(100);
columns.Bound(p => p.State).Width(70);
columns.Bound(p => p.AssignedTo);
@*
columns.Command(command => command.Custom("View Details").Click("showDetails"));
*@
})
.ClientDetailTemplateId("detailsTemplate")
.Pageable()
.Sortable()
.Scrollable(src => src.Height(500))
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("ViewDetails", "Site"))
.PageSize(20)
)
.Events(events =>
{
events.DataBound("dataBoundDetails");
events.DetailExpand("expandDetails");
})
)
@(Html.Kendo().Window().Name("Details")
.Title("Site Details")
.Visible(false)
.Modal(true)
.Draggable(true)
.Width(500)
)
<script id="detailsTemplate" type="text/kendo-tmpl">
@(Html.Kendo().TabStrip()
.Name("TabStrip_#=Id#")
.SelectedIndex(0)
.Items(items =>
{
//Main
items.Add()
.Text("Details")
.Encoded(false)
.Content(@<text>
@if("#= StatusId #" == "1")
{
@Html.Action("SiteRequestView", "Site")
}
else
{
@Html.Action("EvaView", "Site")
}
</text>);
})
.ToClientTemplate())
</script>
<div id =
"griddisplay"
>
@(Html.Kendo().Grid(Model)
.Name(
"MyGrid"
)
.Columns(columns =>
{
columns.Bound(p => p.RegionId).Title(
"Region ID"
).Width(
"100px"
);
columns.Bound(p => p.RegionName).Title(
"Region Name"
).Width(
"150px"
);
})
.Pageable()
.Resizable(r=>r.Columns(
true
))
.Sortable()
.Scrollable(scr => scr.Height(
"200px"
))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action(
"GridTest"
,
"MyController"
)
)
)
)
</div>
#griddisplay {
width
:
520px
;
font-size
:
12px
}
var
data = {
id: 4711,
task: {
name:
"coding"
}
};
var
options1 = {
type:
"POST"
,
dataType:
"json"
,
contentType:
"application/json"
,
data: JSON.stringify(data)
};
$.ajax(
"/api/Person/"
, options1);
var
options2 = {
transport: {
read: {
url:
"/api/Person/"
,
type:
"POST"
,
dataType:
"json"
,
contentType:
"application/json"
,
data: JSON.stringify(data)
}
}
};
var
datasource =
new
kendo.data.DataSource(options2);
datasource.read();
Reading via Ajax
{"id":4711,"task":{"name":"coding"}}
Reading via Datasource (with stringify)
0=%7B&1=%22&2=i&3=d&4=%22&5=%3A&6=4&7=7& (rest stripped)
Reading via Datasource (without stringify)
id=4711&task%5Bname%5D=coding
<
script id="TopRoleEditorTemplate" type="text/x-kendo-template">
<table >
<tr>
<td align="right">
<label for="RoleCode" class="k-Label">
<span id="rolename" style="padding: 0px 1px 0px 1px; font-family: Verdana; color: Red; font-size:xx-small; font-weight:bold">* </span>
Service Owner Group:</label>
</td>
<td>
<input type="RoleCode" id="RoleCode" name="RoleCode" class="k-textbox" style="width: 200px" data-bind="value:RoleCode"
required validationMessage="Service Owner Group is required" />
<span class="k-invalid-msg" data-for="RoleCode"></span>
</td>
</tr>
when the popup is submitted i can see a div is generated with a hard coded margin (0.5em) , becuase of this the validation message appears away from (not inline) the input control<
ul
id
=
"menu"
>
<
li
lang
=
"en"
> Home </
li
>
<
li
lang
=
"en"
> Profile </
li
>
<
li
>
<
div
id
=
"search-box"
>
<
input
type
=
"text"
id
=
"searchfor"
class
=
"k-textbox"
/>
<
button
class
=
"k-button"
id
=
"search"
lang
=
"en"
>search</
button
>
</
div
>
</
li
>
<
li
>
<
select
id
=
"select_lang"
>
<
option
lang
=
"en"
value
=
"en"
> English </
option
>
<
option
lang
=
"en"
value
=
"gr"
> Greek </
option
>
</
select
>
</
li
>
</
ul
>
window.lang =
new
jquery_lang_js();
// Create translator
$(document).ready(
function
() {
$(
"#menu"
).kendoMenu();
$(
"#select_lang"
).kendoDropDownList({
change: onLangChange
});
window.lang.run();
//start translator
function
onLangChange() {
var
value = $(
"#select_lang"
).val();
window.lang.change(value);
//var dropDownLanguage = $("#select_lang").data("kendoDropDownList");
//dropDownLanguage.refresh();
}
});
jquery_lang_js.prototype.lang.gr = {
'Home'
:
'Αρχική Σελίδα'
,
'Profile'
:
'Προφίλ'
,
'World Events'
:
'Παγκόσμια Γεγονότα'
,
'Documents'
:
'Έγγραφα'
,
'Organizations'
:
'Οργανώσεις'
,
'search'
:
'αναζήτηση'
,
'English'
:
'Αγγλικά'
,
'Greek'
:
'Ελληνικά'
}
<
div
id
=
"kw"
/>
var kendoWindow = $("#kw").kendoWindow({
content: "Page2.html",
close: function (e) { alert('closed'); }
});
<
input
id
=
"number"
value
=
"123"
/>
<
buton
id
=
"ok"
>OK</
button
>