Thanks, but I was going a different direction.
I am trying to use AJAX to call my partial page. I can successfully get the partial page controller to fire off with the model returned. The grid will not load or show up on the page.
not sure what the issue is.
Thanks Jay.
here is index view
@model Jlo4MVC.Models.UserToSend
@{
ViewBag.Title =
"JLO"
;
}
<div id=
"userinput"
class=
"row"
>
<ul class=
"userrentry"
>
<li>
@Html.Label(
"User ID"
)
@Html.Kendo().TextBox().Name(
"searchuserid"
)
</li>
<li>
@Html.Kendo().Button().Name(
"findUser"
).Content(
"Search for Sessions"
).HtmlAttributes(
new
{ @class =
"k-button"
})
</li>
</ul>
</div>
<div id=
"sessionsfound"
class=
"row grid-centered"
style=
"display:none"
>
</div>
<div id=
"success"
class=
"row grid-centered"
style=
"display:none"
>
</div>
<script type=
"text/javascript"
>
$(
'#findUser'
).click(
function
() {
var
myurl =
'@Url.Action("getSessionsView", "home")'
var
model = { userID: $(
"#searchuserid"
).val() };
$(
'#userinput'
).css(
"display"
,
"none"
);
$(
'#sessionsfound'
).css(
"display"
,
"block"
);
$.ajax({
url: myurl,
type:
"POST"
,
datatype:
"text/plain"
,
data: JSON.stringify(model),
success:
function
(data) {
alert(data);
$(
'#sessionsfound'
).html(data);
}
});
});
</script>
My partial page
@model Jlo4MVC.Models.UserToSend
<div>
@(Html.Kendo().Grid<Jlo4MVC.Models.SessiondataDTO>()
.Name(
"VSM_Grid"
)
.AutoBind(
false
)
.DataSource(data => data
.Ajax()
.Model(model =>
{
model.Id(m => m.id);
})
.Read(read => read.Action(
"sessions_read"
,
"Home"
).Data(
"{ userID: "
+@Model.CustId+
"}"
))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple).Type(GridSelectionType.Row))
.Columns(c =>
{
c.Bound(i => i.id).Title(
"ID"
).Width(10);
c.Bound(i => i.farmName).Title(
"Farm"
).Width(25);
c.Bound(i => i.domainName).Title(
"Domain"
).Width(25);
c.Bound(i => i.applicationName).Title(
"App Name"
).Width(75);
c.Bound(i => i.serverName).Title(
"Server"
).Width(25);
c.Bound(i => i.sessionID).Title(
"Session ID"
).Width(10);
})
))
controller
[AcceptVerbs(
"POST"
)]
public
ActionResult getSessionsView(UserToSend usertosend)
{
return
PartialView(
"_GetSessionsView"
, usertosend);
}
public
ActionResult sessions_read([DataSourceRequest] DataSourceRequest request, UserToSend usertosend)
{
List<SessiondataDTO> sdto =
new
List<SessiondataDTO>();
sdto.Add(
new
SessiondataDTO { applicationName =
"testapplication"
, farmName =
"testFarm"
, domainName =
"MS"
, id = 1, serverName =
"server01"
, userID = usertosend.userID, sessionID = 01 });
sdto.Add(
new
SessiondataDTO { applicationName =
"testapplication4"
, farmName =
"testFarm"
, domainName =
"MS"
, id = 2, serverName =
"server02"
, userID = usertosend.userID, sessionID = 18 });
sdto.Add(
new
SessiondataDTO { applicationName =
"testapplication3"
, farmName =
"testFarm"
, domainName =
"MS"
, id = 3, serverName =
"server12"
, userID = usertosend.userID, sessionID = 15 });
sdto.Add(
new
SessiondataDTO { applicationName =
"testapplication7"
, farmName =
"testFarm"
, domainName =
"MS"
, id = 4, serverName =
"server00"
, userID = usertosend.userID, sessionID = 8 });
DataSourceResult result = sdto.ToDataSourceResult(request);
return
Json(result, JsonRequestBehavior.AllowGet);
}