This question is locked. New answers and comments are not allowed.
Hi,
We are using telerik mvc tabstrip and mvc grids. We have 2 tabs in the tabstrip and each of the tabstrip loads a mvc grid on load. By default, one of the grids contains displays the complete data as returned from server. The other grid is also bound to the same view model but needs to show filtered data which is a sunbet of the data when the second tab is clicked and this grid is loaded.
The code for loading and selecting tabs is shown below:
staticlists.cshtml
<script type="text/javascript">
function onSelect(e) {
var tabstrip = $("#TabStrip").data("tTabStrip");
var item = $("li", tabstrip.element)[$("#itemIndex").val()];
tabstrip.select(item);
}
function OnLoad(e) {
var grid = $("#MyStaticListGrid").data("tgrid");
alert(grid);
}
</script>
@model IEnumerable<CdcSoftware.Pivotal.ThinClient.Common.ViewBag.MetaqueryViewModel>
@(Html.Telerik().TabStrip()
.Name("TabStrip")
.SelectedIndex(1)
.ClientEvents(events => events
.OnSelect("onSelect")
.OnLoad("OnLoad"))
.Items(tabs =>
{
tabs.Add()
.Text("My Static Lists")
.Content(@<text>
@Html.Partial("MyStaticListGrid")
</text>);
tabs.Add()
.Text("All Static Lists")
.Content(@<text>
@Html.Partial("StaticListGrid")
</text>);
})
Grid 1 view:
staticlistgrid.cshtml
<script type="text/javascript">
function onLoad() {
$('tr', this).live('dblclick', function (e) {
var $tr = $(this);
alert('double click ' + $tr.text());
})
}
</script>
@model IOrderedEnumerable<CdcSoftware.Pivotal.ThinClient.Common.ViewBag.MetaqueryViewModel>
@(Html.Telerik().Grid(Model)
.Name("StaticListGrid")
.Columns(columns =>
{
columns.Bound(o => o.Name).Width(120).Title("Static List Name");
if (ViewData["AllSearches"].ToString() != "false") columns.Bound(o => o.ListType);
columns.Bound(o => o.Permission);
columns.Bound(o => o.CreatedByEmployeeName);
columns.Bound(o => o.CreateDate);
columns.Bound(o => o.EditedByEmployeeName);
columns.Bound(o => o.EditDate);
})
//.DataBinding(dataBinding => dataBinding.Server().Select(
// "_CustomBinding",
// "Metaquery"))
.ClientEvents(events => events.OnLoad("onLoad"))
.DataBinding(dataBinding => dataBinding.Ajax().Select("_CustomBinding",
"Metaquery"))
.HtmlAttributes(new { style = "text-align:left" })
//.RowAction(row =>
// {
// row.HtmlAttributes["style"] = "font-weight: normal; font-size:1em; font-family:times;";
// })
.Sortable(sorting => sorting
.SortMode(GridSortMode.SingleColumn))
.Scrollable(scroll => scroll.Height("385px"))
.EnableCustomBinding(true)
)
Grid 2 view:
@model IOrderedEnumerable<CdcSoftware.Pivotal.ThinClient.Common.ViewBag.MetaqueryViewModel>
@(Html.Telerik().Grid(Model)
.Name("MyStaticListsGrid")
.Columns(columns =>
{
columns.Bound(o => o.Name).Width(120).Title("Static List Name");
if (ViewData["AllSearches"].ToString() != "false") columns.Bound(o => o.ListType);
})
.DataBinding(dataBinding => dataBinding.Ajax().Select("_CustomBinding",
"Metaquery"))
.HtmlAttributes(new { style = "text-align:left" })
.Sortable(sorting => sorting
.SortMode(GridSortMode.SingleColumn))
.Scrollable(scroll => scroll.Height("385px"))
)
How can I dynamically load "MyStaticListsGrid" when "My Static Lists" tab is clicked and how do I filter this grid on "Permission" field?
Regards,
Murali
We are using telerik mvc tabstrip and mvc grids. We have 2 tabs in the tabstrip and each of the tabstrip loads a mvc grid on load. By default, one of the grids contains displays the complete data as returned from server. The other grid is also bound to the same view model but needs to show filtered data which is a sunbet of the data when the second tab is clicked and this grid is loaded.
The code for loading and selecting tabs is shown below:
staticlists.cshtml
<script type="text/javascript">
function onSelect(e) {
var tabstrip = $("#TabStrip").data("tTabStrip");
var item = $("li", tabstrip.element)[$("#itemIndex").val()];
tabstrip.select(item);
}
function OnLoad(e) {
var grid = $("#MyStaticListGrid").data("tgrid");
alert(grid);
}
</script>
@model IEnumerable<CdcSoftware.Pivotal.ThinClient.Common.ViewBag.MetaqueryViewModel>
@(Html.Telerik().TabStrip()
.Name("TabStrip")
.SelectedIndex(1)
.ClientEvents(events => events
.OnSelect("onSelect")
.OnLoad("OnLoad"))
.Items(tabs =>
{
tabs.Add()
.Text("My Static Lists")
.Content(@<text>
@Html.Partial("MyStaticListGrid")
</text>);
tabs.Add()
.Text("All Static Lists")
.Content(@<text>
@Html.Partial("StaticListGrid")
</text>);
})
Grid 1 view:
staticlistgrid.cshtml
<script type="text/javascript">
function onLoad() {
$('tr', this).live('dblclick', function (e) {
var $tr = $(this);
alert('double click ' + $tr.text());
})
}
</script>
@model IOrderedEnumerable<CdcSoftware.Pivotal.ThinClient.Common.ViewBag.MetaqueryViewModel>
@(Html.Telerik().Grid(Model)
.Name("StaticListGrid")
.Columns(columns =>
{
columns.Bound(o => o.Name).Width(120).Title("Static List Name");
if (ViewData["AllSearches"].ToString() != "false") columns.Bound(o => o.ListType);
columns.Bound(o => o.Permission);
columns.Bound(o => o.CreatedByEmployeeName);
columns.Bound(o => o.CreateDate);
columns.Bound(o => o.EditedByEmployeeName);
columns.Bound(o => o.EditDate);
})
//.DataBinding(dataBinding => dataBinding.Server().Select(
// "_CustomBinding",
// "Metaquery"))
.ClientEvents(events => events.OnLoad("onLoad"))
.DataBinding(dataBinding => dataBinding.Ajax().Select("_CustomBinding",
"Metaquery"))
.HtmlAttributes(new { style = "text-align:left" })
//.RowAction(row =>
// {
// row.HtmlAttributes["style"] = "font-weight: normal; font-size:1em; font-family:times;";
// })
.Sortable(sorting => sorting
.SortMode(GridSortMode.SingleColumn))
.Scrollable(scroll => scroll.Height("385px"))
.EnableCustomBinding(true)
)
Grid 2 view:
@model IOrderedEnumerable<CdcSoftware.Pivotal.ThinClient.Common.ViewBag.MetaqueryViewModel>
@(Html.Telerik().Grid(Model)
.Name("MyStaticListsGrid")
.Columns(columns =>
{
columns.Bound(o => o.Name).Width(120).Title("Static List Name");
if (ViewData["AllSearches"].ToString() != "false") columns.Bound(o => o.ListType);
})
.DataBinding(dataBinding => dataBinding.Ajax().Select("_CustomBinding",
"Metaquery"))
.HtmlAttributes(new { style = "text-align:left" })
.Sortable(sorting => sorting
.SortMode(GridSortMode.SingleColumn))
.Scrollable(scroll => scroll.Height("385px"))
)
How can I dynamically load "MyStaticListsGrid" when "My Static Lists" tab is clicked and how do I filter this grid on "Permission" field?
Regards,
Murali