I thought I had everything working but realized when I clicked on the update button, the values from the custom editor are not getting passed to the controller. It's the original values from the select grid row.
My grid is defined as follows and loads data correctly.
#(Html.Kendo().Grid<ET.Data.Models.TowTicketModel>()
.Name("gridTicketStatus")
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => {
model.Id(p => p.TicketId);
model.Field(p => p.TicketId).Editable(false);
model.Field(c => c.CreatedDateTime).Editable(false);
model.Field(c => c.AssignedTo).Editable(false);
model.Field(c => c.TicketType).Editable(false);
model.Field(c => c.Customer.Name).Editable(false);
model.Field(c => c.Description).Editable(false);
// model.Field("TicketStatus", typeof(TowTicketStatusModel));
})
.Read(read => read.Action("GetTowTickets", "TowDriver"))
.Update(up => up.Action("UpdateTowDriverTickets", "TowDriver"))
)
.Columns(columns =>
{
columns.Bound(ticket => ticket.TicketId).Title("Id");
columns.Bound(ticket => ticket.CreatedDateTime).Title("Date").Width("120px").Format("{0:MM/dd/yyyy}")
.HeaderHtmlAttributes(new
{
//style = "white-space: nowrap; text-overflow: ellipis;"
#class = "k-grid td"
});
columns.Bound(ticket => ticket.Customer.Name)
.HeaderHtmlAttributes(new
{
//style = "white-space: nowrap; text-overflow: ellipis;"
#class = "k-grid td"
});
columns.Bound(p => p.TicketType)
.ClientTemplate("#: data.TicketType ? data.TicketType.DisplayValue : '' #")
.Title("Type")
.HeaderHtmlAttributes(new
{
//style = "white-space: nowrap; text-overflow: ellipis;"
#class = "k-grid td"
});
columns.Bound(p => p.TicketStatus)
.ClientTemplate("#: data.TicketStatus ? data.TicketStatus.DisplayValue : '' #")
.Title("Status")
.HeaderHtmlAttributes(new
{
//style = "white-space: nowrap; text-overflow: ellipis;"
#class = "k-grid td"
});
columns.Bound(ticket => ticket.Description).HeaderHtmlAttributes(new
{
//style = "white-space: nowrap; text-overflow: ellipis;"
#class = "k-grid td"
})
.HtmlAttributes(new { title = "#= Description #" });
columns.Bound(p => p.AssignedTo)
.ClientTemplate("#: data.AssignedTo ? data.AssignedTo.FullName : '' #")
.Title("AssignedTo")
.HeaderHtmlAttributes(new
{
//style = "white-space: nowrap; text-overflow: ellipis;"
#class = "k-grid td"
});
columns.Bound(ticket => ticket.CreatedBy.FullName).Title("CreatedBy").HeaderHtmlAttributes(new
{
//style = "white-space: nowrap; text-overflow: ellipis;"
#class = "k-grid td"
});
columns.Command(cmd => cmd.Edit());
//columns.Bound(ticket => ticket.AssignedTo.FullName).Title("AssignedTo");
// columns.Bound(ticket => product.UnitsInStock);
})
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("TowTicketDriverEditor"))
// .ToolBar(tb => tb.Save)
.Pageable()
.Sortable()
)
My Editor contains the following.
> #model ET.Data.Models.TowTicketModel
>
>
> #Html.HiddenFor(model => model.TicketId)
>
> <div class="container">
> <div class="row">
>
> <div>
> #Html.LabelFor(model => model.TicketId)
> </div>
>
> <div>
> #Html.LabelFor(model => model.Customer.Name)
>
> #Html.EditorFor(model => model.Customer.Name, new { htmlAttributes = new { disabled = "disabled", #readonly = "readonly" }
> })
> </div>
> <div>
> #(Html.Kendo().DropDownListFor(m => m)
> .Name("TicketStatus")
>
> .DataValueField("TicketId")
> .DataTextField("DisplayValue")
> .Value("StatusId") // .Value(Model.StatusId)
> .DataSource(source =>
> {
> source.Read("GetTowTicketStatuses", "TowDriver")
> .ServerFiltering();
> }))
> </div>
>
> </div> </div>
Finally my controller:
public async Task<ActionResult> UpdateTowDriverTickets([DataSourceRequest] DataSourceRequest request,
TowTicketModel updated)
{
if (updated != null && ModelState.IsValid)
{
await _towProvider.UpdateTowTicketAsync(new UpdateTowTicketRequest(updated));
}
return Json(ModelState.ToDataSourceResult());
}
Again my grid loads, I click the edit button, the popup opens and the dropdownlist is properly populated from the ajax call.
However, I select from the dropdown and click update, the model parameter of UpdateTowDriverTickets doesn't have the value selected from editor dropdown.
I do have a GridForeignKey.cshtml template defined. (Just copied a template from an example.)
An input would be appreciated.
Turns out we had the wrong value in the DataValueField. TicketId was the Id for the grid but not the ID for our dropdownlist. Corrected that and everything appears to be working.
Related
I have a ASP.NET Core Kendo grid which display's list of Users. The grid has pouup mode editor template. The Kendo Grid code looks like this.
#(Html.Kendo().Grid<Anju.PubSTRAT.Web.Areas.Admin.Models.UserViewModel>()
.Name("UserGrid")
.Columns(columns =>
{
columns.Command(command =>
{
if (UserAccessService.CanEdit("User"))
{
command.Edit().UpdateText("Submit").Text(" ");
command.Custom("Clear").Text(" ").IconClass("k-icon k-i-clear-css k-grid-features").HtmlAttributes(new { title = "Clear User", #class = "k-grid-custom" }).Click("User_clearUser");
command.Custom("Email").Text(" ").IconClass("k-icon k-i-envelop").HtmlAttributes(new { title = "Send Welcome Email", #class = "k-grid-custom" }).Click("User_sendWelcomeEmail");
command.Custom("Unlock").Text(" ").IconClass("k-icon k-i-unlock").Visible("function (e) { return (!e.IsLockedOut); }").HtmlAttributes(new { title = "Disable User", #class = "k-grid-custom" }).Click("User_disableUser");
command.Custom("Lock").Text(" ").IconClass("k-icon k-i-lock").Visible("function (e) { return (e.IsLockedOut); }").HtmlAttributes(new { title = "Enable User", #class = "k-grid-custom" }).Click("User_enableUser");
command.Custom("UserFile").Text(" ").IconClass("k-icon k-i-file").HtmlAttributes(new { title = "User Profile File", #class = "k-grid-custom" }).Click("User_openFilePopup");
}
}).Width(75);
columns.Bound(p => p.UserId).Hidden(true);
columns.Bound(p => p.UserName).MinResizableWidth(100);
columns.Bound(p => p.Prefix).MinResizableWidth(50);
columns.Bound(p => p.FirstName).MinResizableWidth(50);
columns.Bound(p => p.LastName).MinResizableWidth(50);
columns.Bound(p => p.Suffix).MinResizableWidth(50);
columns.Bound(p => p.Email).MinResizableWidth(100);
columns.Bound(p => p.PhoneNumber).MinResizableWidth(60);
})
.ToolBar(toolbar =>
{
toolbar.Custom().Text("Reset Filters").HtmlAttributes(new { id = "resetAllGridFilters", #class = "btn-grid-toolbar", onclick = "ResetGridFilter(\"UserGrid\")" });
if (UserAccessService.CanAdd("User"))
{
toolbar.Create().Text("Add New User").HtmlAttributes(new { #class = "btn-grid-toolbar" });
}
if (UserAccessService.IsAnjuAdmin)
{
toolbar.Custom().Text("Flag Reset Security").HtmlAttributes(new { id = "flagResetSecurity",#class = "btn-grid-toolbar", onclick = "User_flagResetSecurity()" });
toolbar.Custom().Text("Unflag Reset Security").HtmlAttributes(new { id = "unFlagResetSecurity",#class = "btn-grid-toolbar", onclick = "User_unFlagResetSecurity()" });
}
toolbar.Custom().Text("Show Disabled Users").HtmlAttributes(new { id = "showHideDisabledUsers", #class = "btn-grid-toolbar", onclick = "showHideDisabledUsers()" });
})
.Pageable(pageable => pageable
.Refresh(true)
.Responsive(false)
.PageSizes(Constants.PageSizes)
.ButtonCount(5))
.Sortable()
.Scrollable()
.Resizable(resize => resize.Columns(true))
.Filterable()
.Events(e => e.DataBound("gridDataBoundAutoFit"))
.Events(e => e.Edit("User_AddEditUser"))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(UserAccessService.PageSize)
.ServerOperation(true)
.Events(e => e.RequestEnd("User_AddProductDetails"))
.Events(events => events.Error("onGridError"))
.Model(model => model.Id(p => p.UserId))
.Read(read => read.Action("GetUserList", "User").Data("getUserDetailsOptions"))
.Create(create => create.Action("AddUser", "User"))
.Update(update => update.Action("UpdateUser", "User")))
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("User").Window(w => w.Height(670).Width(600)))
)
The Editor template is having tab strips and one of tab is having nested Kendo grid.
The Code for the ASP.NET Core Kendo Grid is as follows :
<script id="UserProductSegmentTemplate" type="text/kendo">
#(Html.Kendo().Grid<Anju.PubSTRAT.Web.Areas.Admin.Models.SegmentViewModel>()
.Name("UserProductSegmentGrid#=ProductId#")
.Columns(columns =>
{
columns.Select().Width(50);
columns.Bound(c => c.SegmentId).Width(0).Hidden();
columns.Bound(c => c.Name).Title("Segment Name").Width(100);
})
.Sortable()
.Scrollable()
.PersistSelection()
.NoRecords(records => records.Template("No Records."))
.DataSource(dc => dc.Ajax()
.ServerOperation(true)
.Model(model => model.Id(p => p.SegmentId))
.Read(read => read.Action("GetSegmentList", "Segment", new { productId = 1 }))
)
.ToClientTemplate()
)
</script>
<div class="row">
#(Html.Kendo().Grid<Anju.PubSTRAT.Web.Areas.Admin.Models.ProductViewModel>()
.Name("ProductGrid")
.Columns(columns =>
{
columns.Select().Width(50);
columns.Bound(p => p.ProductId).Hidden(true);
columns.Bound(p => p.Name).MinResizableWidth(200);
columns.Bound(p => p.Identifier).MinResizableWidth(150);
columns.Bound(p => p.GenericName).MinResizableWidth(150);
})
.Pageable(pageable => pageable
.Refresh(true)
.Responsive(true)
.PageSizes(Constants.PageSizes)
.ButtonCount(5))
.Sortable()
.Scrollable()
.Resizable(resize => resize.Columns(true))
.Filterable()
.PersistSelection()
.Events(e => e.Change("onUserProductGridChange"))
.Events(e => e.DataBound("onUserProductDataBound"))
.ClientDetailTemplateId("UserProductSegmentTemplate")
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(UserAccessService.PageSize)
.ServerOperation(true)
.Model(model => model.Id(p => p.ProductId))
.Read(read => read.Action("GetProductList", "Product")))
.ToClientTemplate()
)
</div>
When I click on "Add New User" toolbar button the editor popup opens but grid is not getting rendered and getting "Invalid template" in browser console.
I'm trying to limit the dropdowns in my kendo grid to only contain Products that have been previously mapped to the company chosen in another cell in the row.
I've used a dynamic drop down editor template approach.
However, the ID passed to getCompanyId() is always null and therefore my dropdowns are always null.
View:
#(Html.Kendo().Grid<XXXAppXXX.Models.WeeklyRailPlan>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.WeekNumber);
columns.Bound(c => c.Company).ClientTemplate("#=(data.Company) ? Company.Name : 'Select Company...'#");
columns.Bound(c => c.ServiceCode);
columns.Bound(o => o.Product)
.ClientTemplate("#= (data.Product) ? Product.Name : 'Select Product'#")
.EditorTemplateName("DynamicDropDownList");
//etc
})
.ToolBar(toolbar => {
toolbar.Create();
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Filterable()
.Events(ev => ev
.Remove(#"function(e){setTimeout(function(){$('#grid').data('kendoGrid').dataSource.sync()})}")
)
.Sortable(sortable => {
sortable.SortMode(GridSortMode.SingleColumn);
})
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Sort(p => { p.Add("WeekNumber").Descending(); })
.Model(model => model.Id(p => p.ID))
.Read(read => read.Action("WeeklyRailPlans_Read", "WeeklyRailPlanGrid"))
.Create(create => create.Action("WeeklyRailPlans_Create", "WeeklyRailPlanGrid"))
.Update(update => update.Action("WeeklyRailPlans_Update", "WeeklyRailPlanGrid"))
.Destroy(destroy => destroy.Action("WeeklyRailPlans_Destroy", "WeeklyRailPlanGrid"))
)
)
EditorTemplate called DynamicDropDownList.cshtml
<script type="text/javascript">
function getCompanyId() {
return { CompanyID: '#=ID#' };
}
</script>
#(Html.Kendo().DropDownList()
.Name("Product")
.DataValueField("ID")
.DataTextField("Name")
.DataSource(ds => ds
.Read(read => read.Action("GetProductsForCompany", "Products").Data("getCompanyId")))
)
Controller method GetProductsForCompany (this is always receiving null)
public ActionResult GetProductsForCompany(int CompanyID)
{
return Json(db.Products.Where(e => e.Companies.Any(t =>t.ID == CompanyID)), JsonRequestBehavior.AllowGet);
}
I use code like this:
<script type="text/javascript">
function getCompanyId() {
var gview = $('#grid').data("kendoGrid");
var selectedItem = gview.dataItem(gview.select());
return { CompanyID: selectedItem.ID };
}
</script>
This solution required was:
function getCompanyId() {
var grid = $('#grid').data('kendoGrid');
var dataItem = grid.dataItem(grid.table.find('.k-edit-cell').parents('tr'))
return { CompanyID: dataItem.Company.ID };
}
Hi I have a kendo grid which is responsive using footable plugin. It is working fine. But when i click the pagination it is breaking the ui. Attached the image of the page. Can you pls help to fix this?
#(Html.Kendo().Grid<UCM.UCW.PresentationService.Entity.Dto.Task>()
.Name("ValidationTaskListGrid")
.HtmlAttributes(new { #class = "table-bordered" })
.TableHtmlAttributes(new { #class = "footable" })
.Columns(columns =>
{
columns.Bound(p => p.TaskDueDate)
.Sortable(true)
.Title("Due Date")
.HeaderHtmlAttributes(new { data_class = "expand" });
columns.Bound(p => p.StateCode)
.Sortable(true)
.Title("State")
.HeaderHtmlAttributes(new { data_hide = "phone_s" });
columns.Bound(p => p.DocumentType)
.Sortable(true)
.Title("Document Type")
.HeaderHtmlAttributes(new { data_hide = "phone,phone_s" });
columns.Bound(p => p.Form)
.Sortable(true)
.Title("Form")
.HeaderHtmlAttributes(new { data_hide = "phone,tablet,phone_s" });
columns.Bound(p => p.UnemploymentDocumentId)
.Sortable(true)
.Title("Document ID")
.HeaderHtmlAttributes(new { data_hide = "phone,tablet,phone_s" });
columns.Bound(p => p.TaskSubject)
.Sortable(true)
.Title("Task Name ")
.HeaderHtmlAttributes(new { data_hide = "phone,tablet,phone_s" });
columns.Bound(p => p.TaskAssignedTo)
.Sortable(true)
.Title("Assigned To ")
.HeaderHtmlAttributes(new { data_hide = "phone,tablet,phone_s" });
columns.Bound(p => p.InstanceName)
.Sortable(false)
.Title("Actions")
// .HeaderHtmlAttributes(new { data_hide = "phone,phone_s" })
.HtmlAttributes(new { style = "text-align: center" })
.ClientTemplate("<a href = '" + Url.Action("GetUnemploymentDocument", "UnemploymentDocument",
new { UnemploymentDocumentId = "#=UnemploymentDocumentId#", taskId = "#=TaskId#", taskAssignedToType = "#=TaskAssignedToType#" }) + "' class='btn btn-function'>Start Task</a>");
})
.Pageable(pageable => pageable.ButtonCount(6)
.Messages(m => m.Display("Showing {0}-{1} of {2}")))
.Sortable(sortable => sortable.SortMode(GridSortMode.SingleColumn).AllowUnsort(false))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetValsync", "WorkList"))
//.ServerOperation(WebConstants.EnableServerOperation)
.ServerOperation(true)
.PageSize(AppContextHelper.Instance.ApplicationConfiguration.DefaultViewItem)
.Sort(sort =>
{
sort.Add("TaskDueDate").Descending();
}))
.Events(x => x.DataBound("GridDataBound")
))
I'm using Kendo UI grid with ASP.NET MVC 4
#Html.Label("Status: ")<select id="drStaus" style="width:250px">
<option value="Open">Open</option>
<option value="Pending">Pending</option>
<option value="Other">Closed</option>
</select>
<br /><br />
#(Html.Kendo().Grid((IEnumerable<FeedBackDashBord.Models.FeedBack>)Model)
.Name("grid")
.Columns(columns => {
columns.Bound(o => o.id).Visible(false);
columns.Template(o => Html.ActionLink("Edit", "Edit", new { o.id })).ClientTemplate("Edit").Width(45);
columns.Bound(o => o.CurrentURL).Width("200px").Title("Reported URL");
columns.Bound(o => o.OS).Width("70px");
columns.Bound(o => o.Browser).Width("70px");
columns.Bound(o => o.UserAgent).Width("200px"); ;
columns.Bound(o => o.datetime).Title("Date Time").Width("100px");
columns.Bound(o => o.Description).Title("Description").Width("200px");
columns.Bound(o => o.Email).Width("150px");
columns.Bound(o => o.Status).Width("70px");
columns.Template(o => Html.ActionLink("Details", "Details", new { o.id })).ClientTemplate("Details").Width(65);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.Groupable()
.HtmlAttributes(new { style = "height:900px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("AjaxGrid", "DashBoard").Data("additionalInfo"))
)
)
<script>
function additionalInfo() {
return {
status: $("#drStaus").val()
}
}
$("#drStaus").kendoDropDownList();
</script>
In the above code i have successfully bound the Kendo Grid to a data source. Now i need to implement the following scenario.
when a option value is selected from the "drStaus" dropdown, i want to pass the selected value to the kendogrid and reload the grid according to the selected value.
Try this solution, I use demo model property to bound grid.
In view
#(Html.Kendo().DropDownList()
.Name("drStatus")
.DataTextField("Text")
.DataValueField("Value")
.Events(e => e.Change("Change"))
.BindTo(new List<SelectListItem>() {
new SelectListItem() {
Text = "Open",
Value = "Open"
},
new SelectListItem() {
Text = "Pending",
Value = "Pending"
},
new SelectListItem() {
Text = "Other",
Value = "Other"
}
})
.Value("Open")
)
#(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =>
{
columns.Bound(x => x.Name);
columns.Bound(x => x.Id);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.Groupable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("AjaxGrid", "DashBoard").Data("additionalInfo"))
)
)
And in javaScript
var additionalDataObject;
function additionalInfo() {
var dropdownlist = $("#drStatus").data("kendoDropDownList");
additionalDataObject = {
status: dropdownlist.value()
};
return additionalDataObject;
}
function Change() {
var grid = $("#grid").data("kendoGrid");
var page = grid.dataSource._page;
reloadFilterParameters();
grid.dataSource.page(page);
}
function reloadFilterParameters() {
var dropdownlist = $("#drStatus").data("kendoDropDownList");
additionalDataObject = {
status: dropdownlist.value(),
};
}
I've implemented the above scenario using Kendo Grid ToolBar Template.
http://demos.kendoui.com/web/grid/toolbar-template.html
#(Html.Kendo().Grid((IEnumerable<FeedBackDashBord.Models.FeedBack>)Model)
.Name("grid")
.Columns(columns => {
columns.Bound(o => o.id).Visible(false);
columns.Template(o => Html.ActionLink("Edit", "Edit", new { o.id })).ClientTemplate("Edit").Width(45);
columns.Bound(o => o.CurrentURL).Width("200px").Title("Reported URL");
columns.Bound(o => o.OS).Width("70px");
columns.Bound(o => o.Browser).Width("70px");
columns.Bound(o => o.UserAgent).Width("200px"); ;
columns.Bound(o => o.datetime).Title("Date Time").Width("100px");
columns.Bound(o => o.Description).Title("Description").Width("200px");
columns.Bound(o => o.Email).Width("150px");
columns.Bound(o => o.Status).Width("70px");
columns.Template(o => Html.ActionLink("Details", "Details", new { o.id })).ClientTemplate("Details").Width(65);
})
.ToolBar(toolbar =>
{
toolbar.Template(#<text>
<div class="toolbar">
<label class="category-label" for="category">Status:</label>
#(Html.Kendo().DropDownList()
.Name("drStaus")
.OptionLabel("All")
.DataTextField("Text")
.DataValueField("Value")
.AutoBind(false)
.Events(e => e.Change("categoriesChange"))
.DataSource(ds =>
{
ds.Read("ToolbarTemplate_Categories", "DashBoard");
})
)
</div>
</text>);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.Groupable()
.HtmlAttributes(new { style = "height:900px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("AjaxGrid", "DashBoard").Data("additionalInfo"))
)
)
<script>
function additionalInfo() {
return {
status: $("#drStaus").val()
}
}
$("#drStaus").kendoDropDownList();
</script>
<script>
function categoriesChange() {
var value = this.value(),
grid = $("#grid").data("kendoGrid");
if (value) {
grid.dataSource.filter({ field: "Status", operator: "eq", value: value });//parseInt(value)
} else {
grid.dataSource.filter({});
}
}
</script>
i have a problem with a DropdownList control.
i have a Grid with a popup edditing and when i show a popup the DropDownList doesnt show any data, im using MVC4 and KendoUI controls
this is the code.
The Grid.
#(Html.Kendo().Grid<CashControl.Models.Usuario>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.nombre).Width(100);
columns.Bound(p => p.nombreUsuario).Width(100);
columns.Bound(p => p.email).Width(100);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("DropDownListUsuarios"))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.idUsuario);
})
.Create(update => update.Action("EditingInline_Create", "Grid"))
.Read(read => read.Action("UsuariosRead", "Configuracion"))
.Update(update => update.Action("EditingInline_Update", "Grid"))
.Destroy(update => update.Action("EditingInline_Destroy", "Grid"))
)
)
The PopUp
<div class="demo-section" style="width: 250px;">
<h2>Products</h2>
#(Html.Kendo().DropDownList()
.Name("products")
.HtmlAttributes(new { style = "width: 250px" })
.DataTextField("nombre")
.DataValueField("idnombre")
.DataSource(source => {
source.Read(read =>
{
read.Action("UsuarioRead", "Configuracion");
});
})
)
</div>
<style scoped>
.demo-section {
width: 250px;
margin: 35px auto 50px;
padding: 30px;
}
.demo-section h2 {
text-transform: uppercase;
font-size: 1.2em;
margin-bottom: 10px;
}
</style>
and the Controller.
public ActionResult UsuarioRead([DataSourceRequest] DataSourceRequest request)
{
IQueryable<Usuario> products = CashControl.Usuario;
var rest = products.Select(n => new
{
idUsuario = n.idUsuario,
nombre = n.nombre,
nombreUsuario = n.nombreUsuario,
email = n.email
});
DataSourceResult result = rest.ToDataSourceResult(request);
return Json(result, JsonRequestBehavior.AllowGet);
}
and this is the JSON result
{"Data":[{"idUsuario":1,"nombre":"Eduardo","nombreUsuario":"Brakyo","email":"eduardomeji#gmail.com"}],"Total":1,"AggregateResults":null,"Errors":null}
i hope anyone can helpme.
Tankx :D
Please try with below code snippet.
Below code will help you to bind your Data in DropDownList but it will not work Kendoui Grid. Means you have create two separate method for Grid and DropDownList.
Controller
public ActionResult UsuarioRead()
{
IQueryable<Usuario> products = CashControl.Usuario;
var rest = products.Select(n => new
{
idUsuario = n.idUsuario,
nombre = n.nombre,
nombreUsuario = n.nombreUsuario,
email = n.email
});
return Json(products, JsonRequestBehavior.AllowGet);
}