Telerik grid custom column building/formatting - c#

I have a telerik grid with a dynamic data source (the grid may use up to roughly 10 totally different models for its data), so I have to build the columns dynamically as well (obviously). One of the columns in the grid (with certain models) is a double representing a time span in milliseconds. What I want to do is format this double to look like a timespan.The telerik code looks like this:
<% Html.Telerik()
.Grid(Model.DynamicGridDataSource)
.Name("statisticalGrid")
.Columns(a => GridHelper.GenerateColumns(a, Model.SelectedReport))
.DataBinding(dataBinding => dataBinding.Ajax().Select("_SelectGrid", "Reports", new { reportId = Model.ReportId, dateFrom = Model.DateFrom, dateTo = Model.DateTo, date = Model.Date, AvailablePlans = Model.AvailablePlans }))
.Sortable(GridSortSettingsBuilder => GridHelper.SortColumns(GridSortSettingsBuilder,
Model.DynamicGridDataSource.GetType(),
Model.SelectedReport))
.Filterable()
.Pageable(page => page.PageSize(25))
.Reorderable(reorder => reorder.Columns(true))
.Groupable
(
groupingSettingsBuilder => GridHelper.GroupColumns(groupingSettingsBuilder,
Model.DynamicGridDataSource.GetType(),
Model.SelectedReport)
)
.ClientEvents(events => events
.OnColumnReorder("onReorder"))
.Render();
and GridHelper.GenerateColumns looks something like this:
public static void GenerateColumns(GridColumnFactory<dynamic> columnFactory, Company.Product.Data.Entity.Report reportStructure)
{
foreach (var columnLayout in reportStructure.ReportCols.OrderBy(o => o.ColumnSequence))
{
var columnBuilder = columnFactory.Bound(columnLayout.ColumnType);
if (columnLayout.ColumnType.Equals("SessionLength") ||
columnLayout.ColumnType.Equals("AverageTime") ||
columnLayout.ColumnType.Equals("TotalTime") ||
columnLayout.ColumnType.Equals("CallTime"))
{
// disable grouping
columnBuilder.Groupable(false);
string dataBindProperty = columnLayout.ColumnType;
if (columnLayout.DataFormat == "{0:T}")
{
//Even though the format looks like time ({0:T}), its actually a double which needs to be formatted here to look like a TimeSpan
}
}
if (!string.IsNullOrEmpty(columnLayout.Label))
{
columnBuilder.Title(columnLayout.Label);
}
if (columnLayout.DataFormat != null && columnLayout.DataFormat == "{0:P}")
{
columnBuilder.Format("{0:P}");
}
if (columnLayout.SumIndicator)
{
if (columnLayout.DataFormat == "{0:T}")
{
AddAggregateToColumnTimeSpan(columnBuilder, Aggregate.Sum);
}
else
{
AddAggregateToColumn(columnBuilder, Aggregate.Sum);
}
}
if (columnLayout.HideIndicator)
{
columnBuilder.Column.Hidden = true;
}
}
}
I was able to format the footer correctly, but I didn't know how to format the rest of the column, since out of the context of the telerik code I don't have access to the item iterator or anything. Any suggestions/ideas? Maybe columnFactory.Bound(columnType).Format(/*something*/)?

You said, "the grid may use up to roughly 10 totally different models for its data", so perhaps instead of trying to represent all those models in one grid, you have one grid for each model. You could put each grid in it's own partial view with the main view using some mechanism for deciding which partial view to load. Here is a simple example.
Controller
public ActionResult DynamicReport
{
//Get your Model
Model.model1 = model_01 = Model.DynamicGridDataSource.GetDynamicModel()
//Get the name of what model is being returned so view knows which
//partial view to load
ViewBag.Message = model_01.Name
...
return View(model_01)
}
In the view have some conditional logic to chose which partial view to load.
View
<h2>View</h2>
#{
string pView = "~/Views/Grid/Partial_01.cshtml";
switch(ViewBag.Message)
{
case "p02":
pView = "~/Views/Grid/Parital_02.cshtml"
break;
.....
}
}
#Html.Partial(pView)
PartialView_01
#model List<Models.Misc>
#(Html.Telerik().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(a => a.Id).Width(120);
columns.Bound(a => a.Name).Width(100);
columns.Bound(a => a.Value).Format("{0:#,##0.00}").Width(100).Title("Price");
})
)
PartialView_02
#model List<Models.Temp>
#(Html.Telerik().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.Name)
.Aggregate(aggregates => aggregates.Count())
.FooterTemplate(#<text>Total Count: #item.Count</text>)
.GroupFooterTemplate(#<text>Count: #item.Count</text>);
columns.Bound(o => o.Start)
.Template(#<text>#item.Start.ToShortDateString()</text>)
.Aggregate(aggreages => aggreages.Max())
.FooterTemplate(#<text>Max: #item.Max.Format("{0:d}")</text>)
.GroupHeaderTemplate(#<text>Max: #item.Max.Format("{0:d}")</text>)
.GroupFooterTemplate(#<text>Max: #item.Max.Format("{0:d}")</text>);
columns.Bound(o => o.Value)
.Width(200)
.Aggregate(aggregates => aggregates.Average())
.FooterTemplate(#<text>Average: #item.Average</text>)
.GroupFooterTemplate(#<text>Average: #item.Average</text>);
columns.Bound(o => o.tsMilliseconds)
.Width(100)
.Aggregate(aggregates => aggregates.Sum())
.Template(#<text>#TimeSpan.FromMilliseconds(#item.tsMilliseconds)</text>)
.Title("TimeSpan")
.FooterTemplate(
#<text>
<div>Sum: #TimeSpan.FromMilliseconds(#Convert.ToDouble(#item.Sum.Value.ToString())) </div>
</text>)
//header if you group by TimeSpan
.GroupHeaderTemplate(#<text>#item.Title: #item.Key (Sum: #TimeSpan.FromMilliseconds(#Convert.ToDouble(#item.Sum.Value.ToString())))</text>)
//footer for grouping
.GroupFooterTemplate(#<text>Sum: #TimeSpan.FromMilliseconds(#Convert.ToDouble(#item.Sum.Value.ToString()))</text>);
})
.Sortable()
.Groupable(settings => settings.Groups(groups => groups.Add(o => o.Start)))
)
And so on, for each different model. With each model having its own partial view you can easily format each grid to fit its model while still having only one main view.

Related

How do I stop a partial View from displaying footer information?

I have a partial view that I am calling by my Index and the Partial view does not have the header inside it, but it still has the footer. I am wondering why this is and how can I remove the footer?
PARTIAL VIEW!!!!!!
#(Html.Kendo().Chart<SQDCDashboard.Core.ViewModels.SafetyChartViewModel>()
.Name("safetyIncident-chart")
.Title("Safety Incidents For ")
.Legend(legend => legend.Position(ChartLegendPosition.Top))
.SeriesDefaults(seriesDefaults => seriesDefaults.Column().Stack(true))
.DataSource(ds => ds.Read(read => read.Action("GetSafetyIncidentChart", "Display").Data("DropDownValue")))
.Series(series =>
{
series.Column(model => model.NumSafeDays).Name("Safe Days").Color("green").CategoryField("Month");
series.Column(model => model.NumIncDays).Name("Incident Days").Color("red").CategoryField("Month");
})
.CategoryAxis(axis => axis.MajorGridLines(lines => lines.Visible(false)))
.ValueAxis(axis => axis.Numeric().Labels(labels => labels.Format("{0}")).Min(0).Max(32))
.Tooltip(tooltip => tooltip.Visible(true).Format("{0}"))
)
return PartialView("YourViewName");
or, If you are returning plain view:
At top of your cshtml:
#{
Layout = null;
}
In controller method:
return View("YourViewName")
Have a look at the view using your partial view. It seems you have code there after including your partial view.

dropdownlist in kendo grid not working

Im trying to use incell editing and use of the http://demos.telerik.com/aspnet-mvc/grid/editing-custom but is can't find my partial view that the dropdownlist should be rendered from.
Partial view (Testview.cshtml)
#using Kendo.Mvc.UI
#(Html.Kendo().DropDownList()
.Name("ResourceType") // Name of the widget should be the same as the name of the property
.DataValueField("Id") // The value of the dropdown is taken from the EmployeeID property
.DataTextField("Name") // The text of the items is taken from the EmployeeName property
.BindTo((System.Collections.IEnumerable)ViewData["defaultResourceType"]) // A list of all employees which is populated in the controller
)
This is my grid:
#(Html.Kendo().Grid<RMS.Admin.ViewModel>()
.Name("ResourceGrid")
.Columns(columns =>
{
columns.Bound(c => c.ResourceId).Hidden();
columns.Bound(c => c.ResourceName);
columns.Bound(c => c.Descritption);
columns.Bound(c => c.ResourceType.Name).ClientTemplate("#=ResourceType.Name#");
columns.Bound(c => c.Approved);
columns.Bound(c => c.IsEnabled);
columns.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(172).Title("Edit/Delete");
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Scrollable()
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(s => s.ResourceId);
model.Field(s => s.ResourceType).DefaultValue(ViewData["defaultResourceType"] as RMS.Admin.ViewModel.ResourceTypeId);
})
.Create(update => update.Action("CreateResource", "Home"))
.Read(read => read.Action("ReadResource", "Home"))
.Update(update => update.Action("SaveSystem", "Home"))
.Destroy(destroy => destroy.Action("RemoveSystem", "Home"))
)
)
Here is a part of my model:
public string ResourceUserId { get; set; }
[UIHint("Testview")]
public ResourceTypeId ResourceType { get; set; }
This is in my controller where i bind the data:
private void GetResourceTypeId()
{
//string [] list = new string[]{"Image", "Document", "Other"};
IList<ViewModel.ResourceTypeId> list = new List<ViewModel.ResourceTypeId>();
var a = new ViewModel.ResourceTypeId
{
Name = "Image",
Id = 1
};
var b = new ViewModel.ResourceTypeId
{
Name = "Document",
Id = 2
};
var c = new ViewModel.ResourceTypeId
{
Name = "Other",
Id = 3
};
list.Add(a);
list.Add(b);
list.Add(c);
ViewData["defaultResourceType"] = list.First();
}
I get this error when trying to render the grid:
The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
What am i missing?
First off your trying to bind just to one item with ViewData["defaultResourceType"] = list.First();. Instead you should bind to your whole list and then set the default option with .Value("1") so that it has "Images" by default.
#(Html.Kendo().DropDownList()
.Name("ResourceType")
.DataValueField("Id")
.DataTextField("Name")
.BindTo((System.Collections.IEnumerable)ViewData["ResourceTypeList"])
.Value(ViewData["DefaultResourceType"])
);
Also for a template for a column in MVC you may just want to set it with EditorTemplateName
columns.Bound(e => e.myColumn).EditorTemplateName("dropdownTemplate")
And then define the template that you want to use somewhere else on the page.
<script id="dropdownTemplate" type="text/x-kendo-template">
#(Html.Kendo().DropDownList()
.Name("myDropDown")
.....
.ToClientTemplate()
)
</script>
If you would like you can also declare it as a stand alone template in your /Views/Shared/ folder. You would not have to add the .ToClientTemplate() or the script tags. You would reference it by the file name. You could then use the template on multiple pages in the project.

Refresh after update Telerik Kendo Grid (MVC)

I have a Kendo Grid with some environments data. One of the fields of the grid is "isDefault" wich recieve 1 or 0 (for true or false). In the database I have a trigger that when some record is set to isDefault = 1 any other record is update to isDefault = 0, just to make sure there is only one default environment.
The Kendo grid is working fine, it binds the data and updates the records just fine but after the update, the grid is not refreshing all the records and if there was, lets say, record 1 with isDefault =1 and I update record 4 to isDefault = 1 the trigger is fired and updates all others records to isDefault = 0 but the grid still showing record 1 with isDefault = 1 and now record 4 with isDefault = 1
This is the code on my view:
Html.Kendo().Grid<Models.Environment>()
.Name("environmentGrid")
.Sortable()
.ToolBar(tb => tb.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Columns(cols =>
{
cols.Bound(c => c.Name).Width(150).Sortable(true);
cols.Bound(c => c.ConnectionString).Width(150).Sortable(true);
cols.Bound(c => c.Template).Width(150).Sortable(true);
cols.Bound(c => c.isDefault).Width(150).Sortable(true);
cols.Bound(c => c.StatusID).Width(150).Sortable(true);
cols.Command(command => { command.Edit();}).Width(60);
})
.DataSource(ds => ds
.Ajax()
.Model(model =>
{
model.Id(m => m.EnvironmentID);
})
.Read(r => r.Action("GetEnvironments", "Admin"))
.Update(update => update.Action("UpdateEnvironments", "Admin"))
.Create(update => update.Action("UpdateEnvironments", "Admin"))
)
and this is the code on my controller:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateEnvironments([DataSourceRequest] DataSourceRequest dsRequest, Environment environment)
{
environment.ModifiedBy = userName;
if (environment != null && ModelState.IsValid)
{
if (environment.EnvironmentID != 0)
{
var toUpdate = xgr.EnviromentRepository.ListAll().FirstOrDefault(p => p.EnvironmentID == environment.EnvironmentID);
TryUpdateModel(toUpdate);
}
xgr.EnviromentRepository.Save(environment);
}
return Json(ModelState.ToDataSourceResult());
}
Thank you in advance for your answers.
I finally get it to work. Added an event handler:
Html.Kendo().Grid<Models.Environment>()
.Name("environmentGrid")
.Sortable()
.ToolBar(tb => tb.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Columns(cols =>
{
cols.Bound(c => c.Name).Width(150).Sortable(true);
cols.Bound(c => c.ConnectionString).Width(150).Sortable(true);
cols.Bound(c => c.Template).Width(150).Sortable(true);
cols.Bound(c => c.isDefault).Width(150).Sortable(true);
cols.Bound(c => c.StatusID).Width(150).Sortable(true);
cols.Command(command => { command.Edit();}).Width(60);
})
.DataSource(ds => ds
.Ajax()
.Model(model =>
{
model.Id(m => m.EnvironmentID);
})
.Events(events =>
{
events.RequestEnd("onRequestEnd"); //I've added this
})
.Read(r => r.Action("GetEnvironments", "Admin"))
.Update(update => update.Action("UpdateEnvironments", "Admin"))
.Create(update => update.Action("UpdateEnvironments", "Admin"))
)
And a Javascript Function:
function onRequestEnd(e) {
if (e.type == "update") {
$("#environmentGrid").data("kendoGrid").dataSource.read();
}
}
Also I needed to modify my ListAll() Method on the EnvironmentRepository to be like this:
public List<XML_Environment> ListAll()
{
_dataContext = new XMLGenEntitiesDataContext(); //I've to add this line. so the context is instantiated every time I call the ListAll Method.
return _dataContext.XML_Environments.OrderBy<XML_Environment, string>(c => c.EnvironmentName).ToList<XML_Environment>();
}
You are returning the wrong object. I don't really know how you get your data, because you did not posted the GET controller, so I'm going to try to guess it. After you updated your data, you need to send them back to the grid. The ModelState does not contain the data you want. Try this:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateEnvironments([DataSourceRequest] DataSourceRequest dsRequest, Environment environment)
{
environment.ModifiedBy = userName;
var updatedRecords = null;//1
if (environment != null && ModelState.IsValid)
{
if (environment.EnvironmentID != 0)
{
var toUpdate = xgr.EnviromentRepository.ListAll().FirstOrDefault(p => p.EnvironmentID == environment.EnvironmentID);
TryUpdateModel(toUpdate);
updatedRecords = xgr.EnviromentRepository.ListAll();//2 -- you might need to add "ToList()", depending on your implementation
}
xgr.EnviromentRepository.Save(environment);
}
return Json(updatedRecords.ToDataSourceResult(request, ModelState));//3
}
Please see this link for a complete example.

Kendo UI Lazy Loading

I am using the following code. Can anybody tell me how will I use the page number instead of scroll bar?
My Index.cshtml page will be like
<div id="CustomerProfile">
<div id="GridCusotmerProfile">
#(Html.Kendo().Grid(Model)
.Name("grdCustomerProfile")
.Columns(coloumns =>
{
coloumns.Bound(p => p.CustomerID).Title("Customer ID");
coloumns.Bound(p => p.UserId).Title("User Id");
coloumns.Bound(p => p.ComapnyName).Title("Company Name");
coloumns.Bound(p => p.ContactPerson).Title("Contact Person");
coloumns.Bound(p => p.AccountNumber).Title("Account Number");
}
)
.Sortable()
.Scrollable(scrollable => scrollable.Virtual(true))
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Read(read => read.Action("Virtualization_Read", "CustomerProfile"))
)
)
</div>
My Controller will be like the following
public List<CustomerProfileModel> CustomerDataSource(int page, int pagesize, int skip, int take)
{
List<CustomerProfileModel> ModelData = new List<CustomerProfileModel>();
take = skip + take + (page * 10);
var CustomerData = (from cp in context.CustomerProfile select cp).OrderBy(x => x.ComapnyName).Take(take).Skip(skip).ToList();
foreach (var items in CustomerData)
{
CustomerProfileModel Model = new CustomerProfileModel();
Model.CustomerID = items.CustomerID;
Model.AccountNumber = items.AccountNumber;
Model.ComapnyName = items.ComapnyName;
Model.ContactPerson = items.ContactPerson;
Model.UserId = items.UserId;
ModelData.Add(Model);
}
return ModelData;
}
public ActionResult Virtualization_Read([DataSourceRequest] DataSourceRequest request, string page,string pagesize,string skip,string take)
{
return Json(CustomerDataSource(Convert.ToInt32(page),Convert.ToInt32(pagesize),Convert.ToInt32(skip),Convert.ToInt32(take)).ToDataSourceResult(request),JsonRequestBehavior.AllowGet);
}
public List<CustomerProfileModel> CustomerDataSource(int page, int pagesize, int skip, int take)
{
List<CustomerProfileModel> ModelData = new List<CustomerProfileModel>();
take = skip + take + (page * 10);
var CustomerData = (from cp in context.CustomerProfile select cp).OrderBy(x => x.ComapnyName).Take(take).Skip(skip).ToList();
foreach (var items in CustomerData)
{
CustomerProfileModel Model = new CustomerProfileModel();
Model.CustomerID = items.CustomerID;
Model.AccountNumber = items.AccountNumber;
Model.ComapnyName = items.ComapnyName;
Model.ContactPerson = items.ContactPerson;
Model.UserId = items.UserId;
ModelData.Add(Model);
}
return ModelData;
}
public ActionResult Virtualization_Read([DataSourceRequest] DataSourceRequest request, string page,string pagesize,string skip,string take)
{
return Json(CustomerDataSource(Convert.ToInt32(page),Convert.ToInt32(pagesize),Convert.ToInt32(skip),Convert.ToInt32(take)).ToDataSourceResult(request),JsonRequestBehavior.AllowGet);
}
Please let me know if I need something else to get data as lazy loading.
Your on the right tracks, but it is actually a lot easier than you think. Your trying to hand roll functionality that Kendo handles with the `ToDataSourceResult() extension method.
The DataSourceRequest contains all the information needed for database operations, such as ordering, aggregates and paging. So you can simplfy your code down to pretty much the following (NOT TESTED)
public ActionResult Virtualization_Read([DataSourceRequest] DataSourceRequest request)
{
var CustomerData = (from cp in context.CustomerProfile select cp); // don't call toList() this exectues the SQL and pulls data into memory, leave it as a Queryable object so we can pass it to kendo to add its expressions this will the be a Database operation
DataSourceResult result = CustomerData.ToDataSourceResult(request, x => new CustomerProfileModel(){
CustomerID = x.CustomerID;
AccountNumber = x.AccountNumber;
ComapnyName = x.ComapnyName;
ContactPerson = x.ContactPerson;
UserId = x.UserId;
});
return Json(result);
}
For further reading take a look at this link:
http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/ajax-binding
From the Kendo Site:
How do I implement paging, sorting, filtering and grouping?
If your model supports the IQueryable interface or is DataTable the grid will do paging, sorting, filtering, grouping and aggregates automatically. For server binding scenarios no additional steps are required - just pass the IQueryable to the Grid constructor. Check the server binding help topic for additional info.
For ajax binding scenarios the ToDataSourceResult extension method must be used to perform the data processing. Check the ajax binding help topic for additional information. If your model does not implement IQueryable custom binding should be implemented. This means that the developer is responsible for paging, sorting, filtering and grouping the data. More info can be found in the custom binding help topic.
Important:
All data operations will be performed at database server level if the underlying IQueryable provider supports translation of expression trees to SQL. Kendo Grid for ASP.NET MVC has been tested with the following frameworks:
Entity Framework
Linq to SQL
Telerik OpenAccess
NHibernate
.Columns(columns =>
{
columns.Bound(p => p.ID).Title("ID").Width(100).Visible(false);
columns.Bound(p => p.Apply).Title("Apply").Width(100);
columns.Bound(p => p.TaxName).Title("Tax Name").Width(100);
columns.Bound(p => p.TaxPercent).Title("Percent").Width(130);
columns.Bound(p => p.OrderApplied).Title("Oreder Applied").Width(130);
columns.Bound(p => p.Compund).Title("Compund").Width(130);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable(scr=>scr.Height(430))
//.Scrollable(scrollable => scrollable.Virtual(true))
.HtmlAttributes(new { style = "height:430px;" })
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.ID))
.ServerOperation(false)
.Create(update => update.Action("EditingInline_Create", "Taxes"))
.Read(read => read.Action("EditingInline_Read", "Taxes"))
.Update(update => update.Action("EditingInline_Update", "Taxes"))
.Destroy(update => update.Action("EditingInline_Destroy", "Taxes"))
)
)

Rebind grid with combobox, how to get selected value?

I work with Telerik-MVC and I'm trying to rebind a grid when I change the value of a combobox. Everything seems working except I can't get selected value of my combobox.
Here is my code :
Grid :
#{Html.Telerik().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.Col1);
columns.Bound(o => o.Col2);
columns.Bound(o => o.Col3);
})
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("_MyAction", "MyController")
)
.ClientEvents(events => events.OnDataBinding("Grid_onDataBinding"))
}
Combobox :
#(Html.Telerik().ComboBox()
.Name("ComboBox")
.HtmlAttributes(new { id = "ComboBoxCode" })
.BindTo(new SelectList(Model.GroupBy(x => x.Code)
.Select(o => o.First()).ToList(),
"Code", "Code"))
.ClientEvents(events => events
.OnChange("onComboBoxChange")
)
)
Script :
function onComboBoxChange(e) {
$("#Grid").data("tGrid").rebind();
}
function Grid_onDataBinding(e) {
var code = /* I need to get the combobox value here */;
e.data = { myCode: code };
}
Controller :
[GridAction]
public ActionResult _MyAction(string myCode)
{
Console.WriteLine("Code : " + code);
/*
Set new model here
*/
return View(new GridModel(newModel));
}
I tried things like :
var e = document.getElementById("ComboBoxCode");
var code = e.options[e.selectedIndex].text;
But it doesn't work. Can you tell me how to fix this problem and get the right value ?
The problem is that when you rebind the grid, you didn't really use the ComboBox selected value. Your onComboBoxChange function tells the grid to rebind, which it does by going to the _MyAction method. At no point did you pass in the ComboBox value. What you should do is before databinding, grab the selected value and pass it to your controller action. See http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-client-api-and-events.html#OnDataBinding for details. Something like this:
function Grid_onDataBinding(e) {
var combobox = $('#ComboBox').data('tComboBox');
e.data = { code: combobox.value };
}
(Note that I actually haven't done any work with the ComboBox, so this isn't tested, but this should at least get you on the right path. See ComboBox documentation.)

Categories

Resources