Hi,
Currently in KendoUI for MVC, one can load the columns for a KendoGrid by writing this in the view,
@(Html.Kendo().Grid<Object>(
.Name("Some name")
.Columns(columns =>
{
columns.LoadSettings((IEnumerable<GridColumnSettings>)ViewData["Columns"]);
})
// ...
)
where ViewData["columns"] has been set in the controller.
I'm wondering if there is some similar way of loading several series for a KendoChart. I know I could probably accomplish this using javascript and an AJAX call, but I would rather use Razor for as much as I can, and I would like to avoid making too many server calls.
Thanks!
[HttpPost]public virtual ActionResult CreateTable(IEnumerable<HttpPostedFileBase> files){ string tableName = Request["CreateTableViewModel.TableName"].ToString(); bool blnOk = true; try { if (string.IsNullOrEmpty(tableName)) { ModelState.AddModelError("CreateTableViewModel.TableName", "Table Name is required."); blnOk = false; } if (files == null) { ModelState.AddModelError("files", "CSV file is required"); blnOk = false; } if (!blnOk) { return RedirectToAction(MVC.Data.CreateTable()); } foreach (var hpf in files) { if (hpf.ContentLength == 0) { ModelState.AddModelError("files", "You must select a file to upload."); return RedirectToAction(MVC.Data.CreateTable()); } _sqlService.CreateDatasource(hpf.FileName, tableName); } return RedirectToAction(MVC.Data.Success()); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return RedirectToAction(MVC.Data.CreateTable()); }} public class FloorPlanModel { [ScaffoldColumn(false)] public Guid Id { get; set; } [ScaffoldColumn(false)] public Guid PropertyId { get; set; } public string Name { get; set; } public decimal Bedrooms { get; set; }}@(Html.Kendo().Grid<FloorPlanModel>() .Name("floorPlanGrid") .Columns(columns => { columns.Bound(p => p.Name); columns.Bound(p => p.Bedrooms).Width(80).EditorTemplateName("Bedrooms"); }) .DataSource(dataSource => dataSource .Ajax() .Batch(true) .ServerOperation(false) .Model(model => { model.Id(p => p.Id); model.Field(p => p.PropertyId).DefaultValue(Model.Id); model.Field(p => p.Bedrooms).DefaultValue(1); }) ))
|
|
<div id="view">
<input type="text" data-bind="value: UserName" required /><input type="text" data-bind="value: Password" required /><button data-bind="click: LogOn">Log On</button></div><script>$(document).ready(function () { var validatable = $("#view").kendoValidator().data("kendoValidator");var viewModel = { LogOn: function () {var userName = this.get("UserName"); var password = this.get("Password"); if (validatable.validate()) { //What should be done here in order to send username and password? }}};kendo.bind($("#view"), viewModel);}); </script>
public class AccountController : Controller {
[HttpPost] public ActionResult LogOn(LogOnModel model, string returnUrl) {if (ModelState.IsValid) { if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } }
return View(model);
} }
@(Html.Kendo().Grid<Mobooka.Models.Campaign>() .Name("CampaignsGrid") .Columns(columns => { columns.Bound(o => o.CampaignID).Title("ID").Width(80); columns.Bound(o => o.Offer.OfferName).Title("Offer"); columns.Bound(o => o.Offer.Advertiser.Company.CompanyName).Title("Advertiser").Width(180); columns.Bound(o => o.Status.StatusName).Title("Status").Width(100); }) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("GetCampaigns", "Home")) .Filter(filter => filter.Add(f => f.StatusID).Equals(ViewBag.StatusID))
.PageSize(25) .ServerOperation(true) ) .Filterable(filtering => filtering .Enabled(true) ) .Pageable(paging => paging .Enabled(true) .Info(true) .PageSizes(false) .Refresh(true) ) .Scrollable(scrolling => scrolling .Enabled(true) .Height(560) .Virtual(true) ) .Sortable(sorting => sorting .Enabled(true) .AllowUnsort(true) .SortMode(GridSortMode.SingleColumn) ) )
public ActionResult Index() { ViewBag.StatusID = (int)Enumerations.Status.Pending; return View(); } ... public JsonResult GetCampaigns([DataSourceRequest] DataSourceRequest request) { IEnumerable<Campaign> campaigns = db.Campaigns....; return new JsonNetResult(campaigns.ToDataSourceResult(request)); }
.ToolBar(toolbar => {toolbar.Template(
@<text>
<div>
@foreach (var role in Model)
{
<input type="checkbox" name="roleIds" value="@role.Id"/>
@Html.Label(role.Name, new { @class = "checkbox" })
}
@item.CreateButton(new Text="New") //it doesn't work,
</div>
</text>); })
how to change the text of the button? thank's!
{
item.Text = product.Player.FullName;
item.Template .....
}
.....
Thanx.
//item.Action("Index", "Player", new {id = product.Id});
item.
Selected = false;
item.
HtmlAttributes["id"] = product.Player.Id;
}));