Hi,
I'm creating grid with dynamic model structure. But i could not use ForeignKey for dropdowns.
i'am using same viewdata method for non-dynamic grid structure and its working. Because i know model name and model tree.
I want to use dropdowns with dynamic grid structure.
var countries = _adminBusinessLayer.Get("sys_Address_Countries"); //Countries for dropdownViewData["Countries"] = countries;@(Html.Kendo().Grid<dynamic>() .Name("Grid") .Columns(columns => { foreach (System.Data.DataColumn column in Model.Columns) { var c = columns.Bound(column.ColumnName); if (column.ColumnName == "CountryID") { //columns.ForeignKey(d => d.CountryID, (System.Collections.IEnumerable)ViewData["Countries"], "CountryID", "countryNameTr").HeaderTemplate("<i class='fa fa-user'></i> Country"); } }...Hi All,I'm having problems when trying to add a clickable hyperlink to my header template on my grid. The idea is to add a hyperlink with the text of ClientName from the dataitem that will call my controller and pass the ClientCode of the underlying data item.
.Columns(columns =>{ columns.Bound(u => u.ClientName) .ClientGroupHeaderTemplate(Html.ActionLink("\"<#= ClientName#>\"", "blalbalba", "blabla", new { clientCode = "<#= ClientCode #>" }).ToString()); columns.Bound(u => u.Status).Width("50px").Title("Collat").ClientTemplate("<i class='#= Status ? 'fa fa-check fa-3x red-text' : 'fa' #'/>"); columns.Bound(u => u.Quantity).Width("100px"); columns.Bound(u => u.Security).Title("Security"); columns.Bound(u => u.Value).Format("{0:C}") .ClientGroupFooterTemplate("#=kendo.toString(sum, '£0.00') #") .ClientFooterTemplate("#= kendo.toString(sum, '£0.00') #").Width("100px"); columns.Bound(u => u.CollatValue).Format("{0:C}") .ClientGroupFooterTemplate("#=kendo.toString(sum, '£0.00') #") .ClientFooterTemplate("#= kendo.toString(sum, '£0.00') #").Title("Collat. Value").Width("100px");}).NoRecords("No records found").Pageable(pageable => pageable.Refresh(true)).Sortable().Navigatable().AutoBind(true).DataSource(dataSource => dataSource.Ajax().Aggregates(aggregates =>{ aggregates.Add(p => p.Value).Sum(); aggregates.Add(p => p.CollatValue).Sum();}).Group(group => group.Add(x => x.ClientName)).PageSize(100)
cheers
Hi Team,
I have a custom add new row button on each row, which adds a new row adjacent to the current row which works fine with the below js code:
var grid = $("#grid").data("kendoGrid");
customRowDataItem = this.dataItem($(e.currentTarget).closest("tr"));
currentCommissionMemoId = customRowDataItem.uidCommissionMeemoBusiness;
var idx = grid.dataSource.indexOf(customRowDataItem);
console.log(idx);
var newItem = grid.dataSource.insert(idx, {});
var newRow = grid.items().filter("[data-uid='" + newItem.uid + "']");
grid.editRow(newRow);
The issue is, I am trying to do the same after grouping the grid data using the drag and drop grouping option. The add new row acts weird after grouping,
1. New row is not added adjacent to the current row
2. When trying to add a new row in a different page (grid is pageable), does not add a new row at all.
My primary intention is to add a new row inside the group after grouping the kendo grid data, is this possible?
Thank you in advance,
Sam
Hello,
I would like to know if i can add an ActionLink in a column in my DetailTemplate:
The only way I've found is by using a Template , for exemple :
.Columns(col => {
col.Bound(p => p.Etat).Template(@<text>@Html.ActionLink("Edit", "Edit")</text>);
})
But like i'm already in a DetailTemplate , i get an error when i try to do this :
.DetailTemplate(
@<text>
@(Html.Kendo().Grid<Affaire>()
.Name("Affaires_" + item.Id)
.Columns(col => {
col.Bound(p => p.Name).Template(@<text>@Html.ActionLink("Edit", "Edit")
</text>)
Is there another way to make this link work ?
Thanks

using System;using System.Collections.Generic;using System.Linq;using System.Web;namespace webArta.Models{ public class ASoratModel { public long id { get; set; } public String name { get; set; } public String title { get; set; } }}using System;using System.Collections.Generic;using System.Data;using System.Data.SqlClient;using System.Linq;using System.Web;namespace webArta.Models{ public class ASoratService { private String sqlCnStr = functions.GetConnectionString(false); public List<ASoratModel> Read() { List<ASoratModel> data = new List<ASoratModel>(); using (SqlConnection connection = new SqlConnection(sqlCnStr)) { connection.Open(); using (SqlCommand command = new SqlCommand("select * from [test]", connection)) { using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection)) { while (reader.Read()) { ASoratModel m = new ASoratModel(); m.id = (long)reader["id"]; m.title = (string)reader["title"]; m.name = (string)reader["name"]; data.Add(m); } } } } return data; } public void Create(ASoratModel model) { model.name = ""; model.title = ""; String sql = "INSERT INTO [test] (name,title) VALUES ('" + model.name + "','" + model.title + "')"; using (SqlConnection connection = new SqlConnection(sqlCnStr)) { connection.Open(); using (SqlCommand command = new SqlCommand(sql, connection)) { command.ExecuteNonQuery(); } } } public void Update(ASoratModel model) { String sql = "update [test] set name='" +model.name+"',title='"+model.title+"' where id="+model.id; using (SqlConnection connection = new SqlConnection(sqlCnStr)) { connection.Open(); using (SqlCommand command = new SqlCommand(sql, connection)) { command.ExecuteNonQuery(); } } } public void Delete(ASoratModel model) { } }} public ActionResult Read([DataSourceRequest] DataSourceRequest request) { return Json(aSoratService.Read().ToDataSourceResult(request)); } [AcceptVerbs(HttpVerbs.Post)]
[AcceptVerbs(HttpVerbs.Post)] public ActionResult Update([DataSourceRequest] DataSourceRequest request, IEnumerable<ASoratModel> asorats){ foreach(var item in asorats) { aSoratService.Update(item); } return Json(asorats.ToDataSourceResult(request,ModelState)); } @using webArta.Models@using System.Linq@using System.Data @(Html.Kendo().Grid<webArta.Models.ASoratModel>() .Name("grid") .Columns(columns => { columns.Bound(p => p.name); columns.Bound(p => p.title); //columns.Command(c => //{ // c.Edit(); // c.Destroy(); //}); }) .ToolBar(t => { t.Save(); t.Create(); }) .DataSource(dataSource => dataSource .Ajax() .AutoSync(true) .Batch(true) .Model(m => m.Id(p => p.id)) .Read(r => r.Action("Read", "MY_CONTROLLER")) .Create(update => update.Action("Create", "MY_CONTROLLER")) .Update(update => update.Action("Update", "MY_CONTROLLER")) .Destroy(update => update.Action("EditingInline_Destroy", "MY_CONTROLLER")) .ServerOperation(true) ) .Navigatable() .Pageable() .Sortable() .Editable(ed => { ed.Mode(GridEditMode.InCell); ed.CreateAt(GridInsertRowPosition.Bottom); }) .Scrollable() .Filterable() .Resizable(resize => resize.Columns(true)) )
Hi,
In my html page I use a grid with virtual scroll:
Html.Kendo().Grid<dynamic>(). ....
.DataSource(dataSource => dataSource
.Ajax()
.Read( read => read.Action(....))
.Scrollable(scroll =>
{
scroll.Height("100%");
scroll.Virtual(true);
}) ...
Everything works fine except for :
- a special request (filter)
- Only on IE11 (It's OK for Chrome, FF & Edge)
In this case, my browser freezes.
I launched an analysis and it would seem that there is an javascript infinite loop (see attachment)
If I remove the virtual scroll, everything works properly
Regards
How would I execute a custom function when any date has been selected?
I searched for examples, but couldn't find a function that takes into consideration dynamic datepicker ID/class.
Can we add a custom function here without using Events? Or if we have to use events, can we pass the datepicker id/class to the function -- if so how?
My markup:
@(Html.Kendo().DatePicker() .Name(@Model.Name) .Footer("Today - #= kendo.toString(data,'ddd, MMM dd, yyyy') # ") .Min("1/1/1900") .Max("1/1/2200") .Events(e => e.Close("onClose")) //.Enable((Model.SelectedValues != null && Model.SelectedValues.Length > 0) || !Model.AllowNullValue) .Value(string.IsNullOrEmpty(Model.SelectedValues) ? null : Model.SelectedValues .Replace("[OneMonthAgo]", DateTime.Now.AddMonths(-1).Date.ToString()) .Replace("[OneYearAgo]", DateTime.Now.AddYears(-1).Date.ToString()) .Replace("[CurrentDate]", DateTime.Now.Date.ToString()) ) .HtmlAttributes(new { AllowNullValue = Model.AllowNullValue.ToString().ToLower(), Prompt = Model.Prompt, onblur = "DatePickerChangeHandler(this)", Class = "DatePicker" }) )
HI
Everyone always ask how to delete the record,
But my question is :
How to get the destroyed data items from the Grid's dataSource ?
Is there have any official/public method or property ?
Best regards
Chris
HI
dataBound
Fired when the widget is bound to data from its data source.
But why the Destroy command trigger the dataBound event too ???
*XXXXX_Read method not executed while the Destroy command clicked.
--
Incell mode
@(Html.Kendo().Grid<MyCompany.Entity.Models.TXXXXX>)
.Name("XXXXXGrid")
...
.Pageable(pageable => pageable.Enabled(false))
.Columns(columns =>
{
...
columns.Command(command => command.Destroy().Text("Delete")).Width(100);
})
.DataSource(dataSource =>
{
dataSource
.Ajax()
.Batch(true)
//.PageSize(GridConst.PAGE_SIZE)
.Model(model =>
{
model.Id(m => m.UniqueID);
})
.ServerOperation(false)
.Read(read => read.Action("XXXXX_Read", "XXX").Data("xxxxx.filterXXXXXGrid"))
.Events(events =>
{
...
});
})
.Events(events =>
{
events.Change("xxxxx.XXXXXGrid_Change");
events.DataBound("xxxxx.XXXXXGrid_DataBound");
events.Edit("xxxxx.XXXXXGrid_Edit");
})
.HtmlAttributes(new { @style = "height: 100%; min-height: 180px" }))
*Visual Studio 2015
*Telerik DevCraft 2017.2.621.545 (UI for ASP.NET MVC).
Best regards
Chris
