I have applied the Drag and Drop feature my Grid, It is not working for left 2 columns in Chrome and left 3 columns in Edge means when i drag the row by choosing from left 2 columns or some times left 3 columns and try to drop it on other position of row, it will stop working. Here is my code:
<div id="example">
<div id="grid"></div>
</div>
<script>
$(document).ready(function () {
var data = [{
EID: 1,
MilestoneName: "Chai",
MilestoneStart: "",
MilestoneNCD: "",
MilestoneComplete: "",
UnitPrice: 18.0000,
UnitsInStock: 39,
Discontinued: false,
PercComplete: "",
WorkPackagesOpen: "",
PlanTasksCount: "",
Position: 1
}, {
EID: 2,
MilestoneName: "Chang",
MilestoneStart: "",
MilestoneNCD: "",
MilestoneComplete: "",
UnitPrice: 19.0000,
UnitsInStock: 17,
Discontinued: false,
PercComplete: "",
WorkPackagesOpen: "",
PlanTasksCount: "",
Position: 2
}, {
EID: 3,
MilestoneName: "Aniseed Syrup",
MilestoneStart: "",
MilestoneNCD: "",
MilestoneComplete: "",
UnitPrice: 10.0000,
UnitsInStock: 13,
Discontinued: false,
PercComplete: "",
WorkPackagesOpen: "",
PlanTasksCount: "",
Position: 3
}, {
EID: 4,
MilestoneName: "Chef Anton's Cajun Seasoning",
MilestoneStart: "",
MilestoneNCD: "",
MilestoneComplete: "",
UnitPrice: 22.0000,
UnitsInStock: 53,
Discontinued: false,
PercComplete: "",
WorkPackagesOpen: "",
PlanTasksCount: "",
Position: 4
}, {
EID: 5,
MilestoneName: "Chef Anton's Gumbo Mix",
MilestoneStart: "",
MilestoneNCD: "",
MilestoneComplete:"",
UnitPrice: 21.3500,
UnitsInStock: 0,
Discontinued: true,
PercComplete: "",
WorkPackagesOpen: "",
PlanTasksCount: "",
Position: 5
}];
var data = data;
var dataSource = new kendo.data.DataSource({
data: data,
schema: {
model: {
id: "EID",
fields: {
EID: { type: "number" },
MilestoneName: { type: "string" },
MilestoneStart: { type: "date" },
MilestoneNCD: { type: "date" },
MilestoneRNCD: { type: "date" },
MilestoneComplete: { type: "date" },
MilestoneResp: { type: "string" },
MilestoneDelay: { type: "string" },
PlanTasksCount: { type: "string" },
WorkPackagesOpen: { type: "string" },
PercComplete: { type: "string" },
Position: { type: "number" }
}
}
}
});
var grid = $("#grid").kendoGrid({
dataSource: dataSource,
scrollable: false,
selectable: "single row",
dataBound: onDataBound,
columns: [
{ field: "EID", title: "EID", width: "50px", },
{ field: "MilestoneName", title: "Milestones", width: "320px" },
{ field: "MilestoneStart", title: "Start Date", format: "{0:MM/dd/yyyy}", width: "90px" },
{ field: "MilestoneNCD", title: "NCD", format: "{0:MM/dd/yyyy}", width: "90px" },
{ field: "MilestoneRNCD", title: "RNCD", format: "{0:MM/dd/yyyy}", width: "90px" },
{ field: "MilestoneComplete", title: "Complete Date", format: "{0:MM/dd/yyyy}", width: "90px" },
{ field: "MilestoneResp", title: "Milestone Resp", width: "150px"},
{ field: "MilestoneDelay", title: "Milestone Delay", width: "150px" },
{ field: "WorkPackagesOpen", title: "Milestone Delay", width: "150px" },
{ field: "PercComplete", title: "Milestone Delay", width: "150px"},
{ field: "Position", title: "Position", width: "30px" },
]
}).data("kendoGrid");
grid.table.kendoDraggable({
filter: "tbody > tr",
group: "gridGroup",
hint: function (e) {
return $('<div id="DragRow" class="k-grid k-widget"><table><tbody><tr>' + e.html() + '</tr></tbody></table></div>');
},
drag: function (e) {
var grid = $("#grid").data("kendoGrid"),
dataSource = grid.dataSource;
var guid = grid.table.find("tr data-uid");
var target = dataSource.getByUid($(e.currentTarget).data("uid"));
if (target.MilestoneRow <= 5 || target.MilestoneRow >= 100) {
$("#DragRow").html('');
return;
}
}
});
grid.table/*.find("tbody > tr")*/.kendoDropTarget({
group: "gridGroup",
drop: function (e) {
var grid = $(e.sender.element).closest('.k-grid').getKendoGrid(),
dataSource = grid.dataSource;
target = dataSource.getByUid($(e.draggable.currentTarget).data("uid")),
dest = $(e.target);
if (dest.is("th")) {
return;
}
dest = dataSource.getByUid(dest.parent().data("uid"));
if (target == undefined || dest == undefined) {
return false;
}
if (target.MilestoneRow <= 5 || target.MilestoneRow >= 100 || dest.MilestoneRow <= 5 || dest.MilestoneRow >= 100) {
return;
}
//not on same item
if (target.get("uid") !== dest.get("uid")) {
//reorder the items
var tmp = target.get("Position");
target.set("Position", dest.get("Position"));
dest.set("Position", tmp);
dataSource.sort({ field: "Position", dir: "asc" });
}
}
});
});
function onDataBound(e) {
var grid = $("#grid").data("kendoGrid");
var gridData = grid.dataSource.view();
$("#grid tr.k-alt").removeClass("k-alt");
for (var i = 0; i < gridData.length; i++) {
if (gridData[i].MilestoneRow <= 5 || gridData[i].MilestoneRow >= 100) {
grid.table.find("tr[data-uid='" + gridData[i].uid + "']").addClass("backgroundColor");
}
}
}
function getSelectedMilestone() {
var grid = $("#grid").data("kendoGrid");
return grid.dataItem(grid.select());
}
</script>



Hi,
Trying to build a multicolumn form within a tabstrip using div and bootstrap grid tags. Even after reading article about Bootstrap and Kendo, (http://docs.telerik.com/kendo-ui/third-party/using-kendo-with-twitter-bootstrap#nesting-kendo-ui-widgets-and-bootstrap-grid-layout), the layout seems not to work as expected like in:
01.<div class="row">02. <div class="col-sm-6 col-md-6">03. <div class="form-group">04. Name05. @(Html.Kendo().TextBoxFor(m => m.Nome).HtmlAttributes(new { @class = "k-textbox" }))06. </div>07. <div class="form-group">08. Last Change09. @(Html.Kendo().TextBoxFor(m => m.ModifiedOn).HtmlAttributes(new { @class = "k-textbox" }))10. </div>11. </div>12. <div class="col-sm-6 col-md-6">13. <div class="form-group">14. Status15. @(Html.Kendo().TextBoxFor(m => m.Status).HtmlAttributes(new { @class = "k-textbox" }))16. </div>17. <div class="form-group">18. Workflow19. @(Html.Kendo().TextBoxFor(m => m.WorkflowStatus).HtmlAttributes(new { @class = "k-textbox" }))20. </div>21. </div>22.</div>
The expected result would be a form with two columns and fields (2x) on both sides. The code is in a partial view and it is invoked on the tabstrip as follows:
01.@using (Html.BeginForm())02.{03. @Html.AntiForgeryToken()04. 05. @(Html.Kendo().TabStrip()06. .Name("customerRecord")07. .Items(tab =>08. {09. tab.Add().Text("Personal Data")10. .Selected(true)11. .Content(m => Html.Partial("_PersonalData", m));12. })13. )14.}
Is this the way to have it done or not?
Regards,
Marcello

Hi,
I have a requirement to have a TreeList which has up to 4 levels. I have the filter option enabled which gives me a filter to say Contains '' for example. When the first loads it loads with all nodes closed. When I apply the filter it only filters on what is shown directly in the view, so in this case on the top level items. Is there a way that it can filter on any child node as well, such that if a level 4 child node contained '' for example it would show the item expanded with the various parent nodes?
I can set it so that the view is always expanded, but then each time the view is rebound any user alterations to the expanded state are by the expansion.
Thanks,
Neil

Hello,
I have a requirement to filter some prices using pre-defined values like the following:
I can't seem to see a way to do this with the Grid. Is it possible?
Thank you
Lucy

I have a grid with a custom command and a client-side function specified for the grid's DataBound event. In the DataBound function, I hide the custom command on rows where a particular column has a certain value. My code is successfully showing the custom button only on the appropriate rows when the grid is displayed. I've also specified a custom popup editor for the grid.
Skeleton of the grid code is:
@(Html.Kendo().Grid<Models.Task>()
.Name("gridTask")
.Columns(columns =>
{
columns.Bound(task => task.Name);
columns.Bound(task => task.TaskStatus);
columns.Command(cmd =>
{
cmd.Edit();
cmd.Custom("Show Survey").Click("ShowSurvey");
});
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.ServerOperation(false)
.Model(model => model.Id(m => m.Task_ID))
.Read(read => read.Action("ReadTask", "TaskPartial"))
.Update(update => update.Action("UpdateTask", "TaskPartial"))
.Create(update => update.Action("CreateTask", "TaskPartial"))
)
.Events(e =>
{
e.Cancel("EditCancel");
e.DataBound("TaskDataBound");
})
.Pageable()
.Sortable()
.Editable(ed => {
ed.Mode(GridEditMode.PopUp);
ed.TemplateName("TaskEditor");
ed.Window(win => win.Title("Task Editor"));
})
)
And the DataBound function is:
function TaskDataBound(e) {
// Check the Show Survey button in each task row. Remove the button if the row has a certain value.
$("[id^='gridTask'] tbody tr .k-grid-ShowSurvey").each(function () {
var currentDataItem = $("[id^='gridTask']").data("kendoGrid").dataItem($(this).closest("tr"));
//Check the current dataItem to see if the button should be removed
if (currentDataItem.testValue == 0) {
$(this).remove();
}
})
}
Now suppose I click Edit on a row which does not show the custom button, and the edits I make do not effect the column determining the visibility of the custom button. When I click Update in the popup editor, the screen is updated as expected. The popup goes away, the updated data is shown, and the grid row still does not show the button.
However, when I click Cancel in the popup editor, the popup goes away but the custom command incorrectly reappears on the grid row, even though the column determining the visibility of the custom command hasn't changed. Why is the custom command mistakenly re-appearing?
I've tried specifying a client-side function for the Cancel event as follows to remove the custom button upon the cancel. Even though I've traced the code to confirm my cancel function is called and the remove() command is hit and executed, the Custom button still comes back.
function EditCancel(e) {
// Check the Show Survey button in each task row. Remove the button if the row has a certain value.
$("[id^='gridTask'] tbody tr").each(function () {
var currentDataItem = $("[id^='gridtask']").data("kendoGrid").dataItem($(this));
//Check the current dataItem to see if the button should be removed
if (currentDataItem.testValue == 0) {
$(this).find(".k-grid-ShowSurvey").remove();
}
})
}

We want to customize the DataSource Export so that it will work against any datasource regardless of the number of columns.
In the example, the cells and columns are hard coded. We want to modify the example to read the datasource and dynamically generated the bolded sections below.
See attached.
Any ideas would be appreciated.
HI
I found a problem about ASP.NET MVC Grid :
After web page loaded, the grid is empty (AutoBind(false), so there have no any data),
Click any column header (will invoke column sorting) but read action invoked unexpectedly,
even if ServerOperation(false).
@(Html.Kendo().Grid<HIS.Entity.Models.TYourModel1>()
.Name("SelectionGrid")
... Sortable is true ...
.AutoBind(false)
.Pageable(pageable => pageable.Enabled(false))
.Columns(columns =>
{
columns.Bound(column => column.xxxxx).Hidden();
})
.DataSource(dataSource =>
{
dataSource.Ajax()
.Batch(true)
.Model(model => model.Id(m => m.Key1))
.PageSize(20)
.ServerOperation(false)
.Events(events =>
{
events.DefaultEvents();
})
.Read(read => read.Action("Selection_Read", "YourController").Data("filterSelectionGrid"));
})
.Events(events =>
{
})
.HtmlAttributes(new { @style = "height: 85%; min-height: 180px" }))
Grid sorting ServerOperation(false) behavior not matched with description -
'... If set to false ... paging, sorting, filtering ... will be performed client-side' :
// Summary:
// Sets the operation mode of the DataSource. By default the DataSource will make
// a request to the server when data for paging, sorting, filtering or grouping
// is needed. If set to false all data will be requested through single request.
// Any other paging, sorting, filtering or grouping will be performed client-side.
//
// Parameters:
// enabled:
// True(default) if server operation mode is enabled, otherwise false.
public TDataSourceBuilder ServerOperation(bool enabled);
UI for ASP.NET MVC R2 2017 SP1
Visual Studio 2015 Enterprise
Best regards
Chris

