This is a migrated thread and some comments may be shown as answers.

The first time I select an item from a DropDownList and tab out of the cell it clears the clear

1 Answer 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Larry
Top achievements
Rank 1
Larry asked on 03 Sep 2014, 04:53 PM
I have a grid where the first time I select an item from a DropDownList and tab out of the cell, the cell show dirty (red mark) but the cell blanks and does not show the selected item.   If I tab back into the cell and select an item from the DropDownList a second time, then the cell remembers the selection.   This happens on all DropDownList on the grid.    The following is my grid code:

@(Html.Kendo().Grid<IRISWeb.Models.CAS.Timecard>()
    .Name("Grid")
    .Columns(c =>
    {
        c.Command(command => { command.Destroy(); }).Width(120).Lockable(true).Locked(true);
        c.Bound(p => p.Task_Date).Width(120).Lockable(true).Locked(true).EditorTemplateName("IRISDate");
        c.ForeignKey(p => p.Activity_Key, (System.Collections.IEnumerable)ViewData["Activities"], "Activity_Key", "NameDesc").Width(350).Lockable(true);
        
        c.ForeignKey(p => p.Project_Key, (System.Collections.IEnumerable)ViewData["Projects"], "Project_Key", "NameDesc").Width(350);
        c.ForeignKey(p => p.ProjectSub_Key, (System.Collections.IEnumerable)ViewData["ProjectSubs"], "ProjectSub_Key", "NameDesc").EditorTemplateName("ProjectSub").Width(200);
        
        c.Bound(p => p.Crew_Num).Width(120);
        c.ForeignKey(p => p.Employee_Key, (System.Collections.IEnumerable)ViewData["Employees"], "Employee_Key", "EmployeeNumFullName").Width(350);
        c.Bound(p => p.Labor_Quantity).HtmlAttributes(new { style = "text-align: right" }).Width(120);
        c.ForeignKey(p => p.Pay_Type_Key, (System.Collections.IEnumerable)ViewData["Pay_Types"], "Pay_Type_Key", "NameDesc").Width(150);
        c.ForeignKey(p => p.Premium_Key, (System.Collections.IEnumerable)ViewData["Premiums"], "Premium_Key", "NameDesc").Width(150);
        c.Bound(p => p.Override_Labor_Rate).Format("{0:c}").HtmlAttributes(new { style = "text-align: right" }).Width(200);
        c.Bound(p => p.Production).HtmlAttributes(new { style = "text-align: right" }).Width(130);
        c.Bound(p => p.Equipment_Quantity).HtmlAttributes(new { style = "text-align: right" }).Width(150);
        c.ForeignKey(p => p.Equipment_Key, (System.Collections.IEnumerable)ViewData["Equipments"], "Equipment_Key", "NameDesc").Width(350);
        c.Bound(p => p.Equipment_Unit_Cost).Format("{0:c}").HtmlAttributes(new { style = "text-align: right" }).Width(120);
        c.Bound(p => p.Material_Quantity).HtmlAttributes(new { style = "text-align: right" }).Title("Mat. Qty").Width(120);
        c.ForeignKey(p => p.Inventory_Location_Key, (System.Collections.IEnumerable)ViewData["Inventory_Locations"], "Inventory_Location_Key", "NameDesc").Width(350);
        c.ForeignKey(p => p.UOM_Key, (System.Collections.IEnumerable)ViewData["UOMs"], "UOM_Key", "NameDesc").Width(100);
        c.Bound(p => p.Material_Description).Title("Mat. Description").Width(120);
        c.Bound(p => p.Material_Unit_Cost).Format("{0:c}").HtmlAttributes(new { style = "text-align: right" }).Title("Mat. Unit Cost").Width(150);
        c.ForeignKey(p => p.Resource_Item_Key, (System.Collections.IEnumerable)ViewData["Resource_Items"], "Resource_Item_Key", "Name").Width(350);
        c.Bound(p => p.OutSideServiceDescription).Width(120);
        c.Bound(p => p.OutSideService_Quantity).HtmlAttributes(new { style = "text-align: right" }).Width(100);
        c.Bound(p => p.OutSideServiceCost).Format("{0:c}").HtmlAttributes(new { style = "text-align: right" }).Width(120);
        c.ForeignKey(p => p.Mgt_Unit_Key, (System.Collections.IEnumerable)ViewData["Mgt_Units"], "Mgt_Unit_Key", "NameDesc").Width(350);
        c.ForeignKey(p => p.Program_Key, (System.Collections.IEnumerable)ViewData["Programs"], "Program_Key", "NameDesc").Width(350);
        c.ForeignKey(p => p.Zone_Key, (System.Collections.IEnumerable)ViewData["Zones"], "Zone_Key", "NameDesc").Width(350);
        c.ForeignKey(p => p.RBF_Key, (System.Collections.IEnumerable)ViewData["RBFs"], "RBF_Key", "NameDesc").Width(200);
        c.ForeignKey(p => p.Road_Key, (System.Collections.IEnumerable)ViewData["Roads"], "Road_Key", "FullRoadNumber").Width(200);
        c.ForeignKey(p => p.RoadName_Key, (System.Collections.IEnumerable)ViewData["RoadNames"], "RoadName_Key", "NameDesc").Width(200);
        c.Bound(p => p.Beg_Point).Width(120);
        c.Bound(p => p.End_Point).Width(120);
        c.Bound(p => p.FromLocation).Width(180);
        c.Bound(p => p.ToLocation).Width(180);
        c.ForeignKey(p => p.Reason_Key, (System.Collections.IEnumerable)ViewData["Reasons"], "Reason_Key", "NameDesc").Width(200);
        c.Bound(p => p.Comments).Width(280);
        c.Bound(p => p.EquipmentMiles).HtmlAttributes(new { style = "text-align: right" }).Width(100);
        c.Bound(p => p.EquipmentHours).HtmlAttributes(new { style = "text-align: right" }).Width(100);
        c.Bound(p => p.User1).Width(120);
        c.Bound(p => p.User2).Width(120);
        c.Bound(p => p.User3).Width(120);
        c.Bound(p => p.User4).Width(120);
        c.Bound(p => p.User5).Width(120);
        c.Bound(p => p.User6).Width(120);
        c.Bound(p => p.User7).Width(120);
        c.Bound(p => p.User8).Width(120);
        c.Bound(p => p.User9).Width(120);
        c.Bound(p => p.User10).Width(120);
        c.Bound(p => p.FuelImport).HtmlAttributes(new { style = "text-align: center" }).ClientTemplate("<input type='checkbox' #=FuelImport ? checked='checked' : '' #></input>").Width(200);
        c.Bound(p => p.Error_Message).Width(220);
        c.Bound(p => p.DateStamp).Title("Last Modified").Format("{0: MM/d/yyyy hh:mm:ss}").Width(175);
        c.ForeignKey(p => p.SecurityUser_Key, (System.Collections.IEnumerable)ViewData["SecurityUsers"], "SecurityUser_Key", "UserName").Title("IRIS User").Width(140);
    })
    .ToolBar(toolBar =>
    {
        toolBar.Create();
        toolBar.Save();
    })
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Filterable()
    .Pageable(pageable => pageable
        .Refresh(true)
        .PageSizes(true)
        .ButtonCount(5))
    .Navigatable()
    .Sortable()
    .Scrollable(a => a.Height("auto"))
    .Resizable(resize => resize.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
    .ColumnMenu(m =>
    {
        m.Enabled(true);
        m.Filterable(true);
        m.Sortable(true);
        m.Columns(true);
    })
    .DataSource(ds => ds
        .Ajax()
        .Batch(true)
        .ServerOperation(true)
        .PageSize(20)
        .Events(e => 
        {
            e.Error("error_handler");
            //e.Change("onChange");
        })
        .Sort(s => s.Add(t => t.Task_Date))
        .Model(model =>
        {
            model.Id(m => m.Timecard_Key);
            model.Field(m => m.Equipment_Unit_Cost).Editable(false);
            model.Field(m => m.UOM_Key).Editable(false);
            model.Field(m => m.FuelImport).Editable(false);
            model.Field(m => m.DateStamp).Editable(false);
            model.Field(m => m.SecurityUser_Key).Editable(false);
            model.Field(m => m.SecurityUser_Key).DefaultValue(ViewData["defaultSecurityUser"]);
            model.Field(m => m.Timecard_Key).DefaultValue("1600000000");
            model.Field(m => m.DateStamp).DefaultValue(DateTime.Now);
        })
        .Read(r => r.Action("Read", "Timecard").Type(HttpVerbs.Get))
        .Create(c => c.Action("Create", "Timecard").Type(HttpVerbs.Post))
        .Update(u => u.Action("Update", "Timecard").Type(HttpVerbs.Post))
        .Destroy(d => d.Action("Destroy", "Timecard").Type(HttpVerbs.Post))

    )

)

<script>
    function error_handler(e) {
        if (e.errors) {
            var message = "Errors:\n";
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n";
                    });
                }
            });
            alert(message);
        }
    }

    function onChange(e) {
        if (e.action == "itemchange") {
                switch (e.field) {
                    case "Project_Key":
                        var model = e.items[0];
                        model.set("ProjectSub_Key", "");
                        break;
                    case "Inventory_Location_Key": 
                        var model = e.items[0];
                        model.set("UOM_Key", "");
                        break;
                };
        }
     
    }

 
    function filterProjectSubs() {
        var model = getCurrentEditedModel();
        return {
            Project_Key:model.Project_Key
        };
    }

    function filterInventoryUOM() {
        var model = getCurrentEditedModel();
        return {
            Inventory_Location_Key: model.Inventory_Location_Key
        };
    }

    function getCurrentEditedModel() {
        var grid = $("#Grid").data("kendoGrid");
        var editRow = grid.tbody.find("tr:has(.k-edit-cell)");
        return grid.dataItem(editRow);
    }


</script>

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 04 Sep 2014, 02:30 PM
Hi Larry,

I have responded to the same question in the support ticket that you opened. Please check your response there. Lets keep the communication in a single thread, as it will be easier for us to track down each questions.

Regards,
Kiril Nikolov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Larry
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or