Telerik Forums
UI for ASP.NET MVC Forum
8 answers
192 views
Hi there,

I have a kendo grid which uses a custom pop up editor which contains an editor control which works fine on desktop devices but on mobile devices the control is not focusable.

I have found that if I run this bit of javascript manually the ability to type appears to work:

$('#ControlName').data("kendoEditor").refresh()

I have done this via Chrome and emulating the ipad environment.

How can I get this control to work in the modal pop up window as my main user base is mobile based and I would prefer to use this control rather than an ugly text area control with no formatting capabilities.


Here is the grid code:

<div id="row8" class="row">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Running log</h4>
</div>
<div class="panel-body">

@(
Html.Kendo().Grid(Model.RunningLogList)
.Name("RunningLogGrid")
.ToolBar(toolbar => toolbar.Create())
.Editable(edit =>
edit.TemplateName("RunningLogEditor").Mode(GridEditMode.PopUp)
.Window(window =>
{
window.HtmlAttributes(new { @class = "kendo-popup-editor" });
})

)
.Columns(
columns =>
{
columns.Bound(c => c.ID).Visible(false);
columns.Bound(c => c.Action);
columns.Bound(c => c.Information);
columns.Bound(c => c.Added);
columns.Bound(c => c.AddedBy);
columns.Command(c => c.Edit());

}
)
.DataSource(ds =>
ds.Ajax()

.Create(create => create.Action("CreateRunningLogEntry", "New", new { area = "CaseStudy", id = Model.ID.ToString() }).Data("sendAntiForgery"))
.Update(update => update.Action("UpdateRunningLogEntry", "New", new { area = "CaseStudy", id = Model.ID.ToString() }).Data("sendAntiForgery"))
.Events(events => events.Error("NewError_Handler"))
.Model(model =>
{
model.Id(m => m.ID);
model.Field(m => m.ID).DefaultValue(Guid.NewGuid());
model.Field(m => m.Added).DefaultValue(DateTime.Now);
model.Field(m => m.AddedBy).DefaultValue(string.Format("{0} {1}",
Common.Library.Claims.ClaimsHelper.ConvertClaim((System.Security.Claims.ClaimsPrincipal)User,System.Security.Claims.ClaimTypes.GivenName ),
Common.Library.Claims.ClaimsHelper.ConvertClaim((System.Security.Claims.ClaimsPrincipal)User,System.Security.Claims.ClaimTypes.Surname )
)
);
model.Field(m => m.StudentID).DefaultValue(Model.ID);
model.Field(m => m.Action);
model.Field(m => m.Information);


})

).Sortable().Pageable().Groupable().Filterable().HtmlAttributes(new { style = "min-height:300px;" }).Scrollable().ColumnMenu()


)


</div>
</div>


<div class="row">
<div class="btn-group pull-left">
<a href="@Url.Action("Index", "Home", new { area="CaseStudy"})" class="btn btn-warning"><span class="glyphicon glyphicon-backward"></span> Back</a>

</div>
<div class="btn-group pull-right">
<button class="btn btn-danger" type="reset"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
<button class="btn btn-primary" type="submit"><span class="glyphicon glyphicon-ok"></span> Save</button>
</div>

</div>
</div>



Here is the editor code:
@model InclusionManagerMVC.Models.StudentRunningLogModels.StudentRunningLogModel


@Html.HiddenFor(m => m.ID)


<div role="form" style="padding:10px;">



<div class="form-group">
@Html.LabelFor(m => m.Action)

@Html.TextBoxFor(m => m.Action, new { @class = "form-control", placeholder = "Enter action" })

</div>

<div class="form-group">
@Html.LabelFor(m => m.Information)

@Html.Kendo().EditorFor(m => m.Information).HtmlAttributes(new { style = "min-width:100%;" }).Deferred(false)

</div>


<div class="form-group">
@Html.LabelFor(m => m.Added)

@Html.Kendo().DateTimePickerFor(m => m.Added).HtmlAttributes(new { style = "min-width:100%;" })

</div>

<div class="form-group">
@Html.LabelFor(m => m.AddedBy)

@Html.TextBoxFor(m => m.AddedBy, new { @class = "form-control", placeholder = "Enter name of person adding..." })

</div>
<div class="help-block">
<p>There will be a section relating to referring the student to panel. Need to decide how this will be activated. </p>
</div>

@Html.Partial("_ErrorPanel")


</div>
Jelly Master
Top achievements
Rank 1
 answered on 07 May 2014
6 answers
617 views
I have a server bound grid that was working fine.  I needed to change it to an ajax bound grid because I needed to add some custom command buttons.  The editor template for the grid contains a dropdownlist which is populated via ViewData in my controller get method.  When I switch the grid to be ajax bound that dropdownlist is throwing an error:

The ViewData item that has the key 'Proposal_Type_ID' is of type 'System.Int32'
but must be of type 'IEnumerable<SelectListItem>'.<BR>

Do I need to change the way the dropdownlist is populated? Or am I doing something else wrong?


Controller:
public ActionResult GetResearchQuestions([DataSourceRequest]DataSourceRequest request)
{
    User user = new User();
    int user_id = user.GetUserIDByBNLAccount(User.Identity.Name);
    string user_facility_id = UserSession.LastViewedUserFacilityID;
 
    if (UserPermissions.VerifyUserFacility(user_id, user_facility_id))
    {
        using (PASSEntities context = new PASSEntities())
        {
            var vm = (from a in context.Proposal_Research_Questions
                      join b in context.Proposal_Types on a.Proposal_Type_ID equals b.ID
                      where b.User_Facility_ID == user_facility_id
                      orderby a.Sort_Order
                      select new ResearchQuestionViewModel()
                      {
                          ID = a.ID,
                          Proposal_Type_ID = a.Proposal_Type_ID,
                          Proposal_Type_Description = b.Description,
                          Question = a.Question,
                          Type = a.Type,
                          Options = a.Options,
                          Required = a.Required,
                          Active = a.Active
                      }).ToList();
 
            var proposalTypes = (from a in context.Proposal_Types
                                 where a.User_Facility_ID == user_facility_id
                                 select a).ToList();
 
            ViewData["ProposalTypes"] = proposalTypes.Select(m => new SelectListItem { Value = m.ID.ToString(), Text = m.Description }).ToList();
 
            DataSourceResult result = vm.ToDataSourceResult(request);
            return Json(result, JsonRequestBehavior.AllowGet);
        }
    }
    else
    {
        return RedirectToAction("Index");
    }
}


View:
@{
    ViewBag.Title = "Research Questions";
}
 
<h2>Proposal Research Questions</h2>
 
@Html.Partial("LastViewedUserFacility")
 
@{ Html.Kendo().Grid<PASSAdmin.ViewModels.UserFacilityAdmin.ResearchQuestionViewModel>()
    .Name("ResearchQuestions")
    .Columns(columns =>
    {
        columns.Command(command => { command.Edit(); }).Width(50);
        columns.Bound(m => m.Question);
        columns.Bound(m => m.Proposal_Type_Description).Title("Proposal Type");
        columns.Bound(m => m.Required).ClientTemplate("#= Required ? '<img src=\\'/Content/images/icons/check.png\\'' : '' #");
        columns.Bound(m => m.Active).ClientTemplate("#= Active ? '<img src=\\'/Content/images/icons/check.png\\'' : '' #");
        columns.Command(command => command.Custom("SortUp").Click("sortUp"));
        columns.Command(command => command.Custom("SortDown").Click("sortDown"));
        columns.Command(command => { command.Destroy(); }).Width(50);
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("UserFacilityAdmin/ResearchQuestion").Window(window => window.Width(500)))
    .Pageable()
    .Sortable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id(m => m.ID))
        .Create(create => create.Action("AddResearchQuestion", "UserFacilityAdmin"))
        .Read(read => read.Action("GetResearchQuestions", "UserFacilityAdmin"))
        .Update(update => update.Action("UpdateResearchQuestion", "UserFacilityAdmin"))
        .Destroy(destroy => destroy.Action("DeleteResearchQuestion", "UserFacilityAdmin"))
    )
    .Render();
}
 
<script type="text/javascript">
function sortUp(e) {
    e.preventDefault();
    var id = this.dataItem($(e.currentTarget).closest("tr")).id;
    $.post('/UserFacilityAdmin/UpdateResearchQuestionSortOrder', { id: id, sortChange: -1 }, function (data) {
        $('#ResearchQuestions').data('kendoGrid').dataSource.read();
    });
}
function sortDown(e) {
    e.preventDefault();
    var id = this.dataItem($(e.currentTarget).closest("tr")).id;
    $.post('/UserFacilityAdmin/UpdateResearchQuestionSortOrder', { id: id, sortChange: 1 }, function (data) {
        $('#ResearchQuestions').data('kendoGrid').dataSource.read();
    });
}
</script>



EditorTemplate: (the first field is the one causing the error)
@model PASSAdmin.ViewModels.UserFacilityAdmin.ResearchQuestionViewModel
 
<div class="editor-label">
    @Html.Label("Proposal Type")
</div>
<div class="editor-field">
    @Html.DropDownListFor(model => model.Proposal_Type_ID,  (List<SelectListItem>) ViewData["ProposalTypes"], "(Select One)")
    @Html.ValidationMessageFor(model => model.Proposal_Type_ID)
</div>
 
<div class="editor-label">
    @Html.Label("Question")
</div>
<div class="editor-field">
    @Html.TextAreaFor(model => model.Question, new { style = "width:300px;height:50px;" })
    @Html.ValidationMessageFor(model => model.Question)
</div>
 
<div class="editor-label">
    @Html.Label("Type")
</div>
<div class="editor-field">
    @Html.DropDownListFor(model => model.Type, new SelectList(Model.QuestionTypes, "Value""Text"), "(Select One)")
    @Html.ValidationMessageFor(model => model.Type)
</div>
 
<div class="editor-label">
    @Html.Label("Options")
</div>
<div class="editor-field">
    @Html.TextAreaFor(model => model.Options, new { style = "width:300px;height:50px;" })
    @Html.ValidationMessageFor(model => model.Options)
</div>
 
<div class="editor-label">
    @Html.Label("Required")
</div>
<div class="editor-field">
    @Html.CheckBoxFor(model => model.Required)
    @Html.ValidationMessageFor(model => model.Required)
</div>
 
<div class="editor-label">
    @Html.Label("Active")
</div>
<div class="editor-field">
    @Html.CheckBoxFor(model => model.Active)
    @Html.ValidationMessageFor(model => model.Active)
</div>










Stephen
Top achievements
Rank 1
 answered on 06 May 2014
3 answers
372 views
I have a Kendo().Button on a page that, when clicked, fires a click event to open a Kendo().Window in order to display an alert.  This works fine.  But, if I add a $(document).ready function  to open the window when the document is ready, it does not open the window, and the button does not render properly.

Instead of rendering as a <button> with an <img> property, instead it renders as a plain <button> no image,

Code follows:

​
@{
                            if (@Model.IsClinicalAlert) {
                            @(Html.Kendo().Button()
                                .Name("redalertbutton")
                                .ImageUrl(Url.Content("~/img/patient_alert_red.bmp"))
                                .HtmlAttributes(new { type = "button" })
                                .Events(ev => ev.Click("onAlertClick")))
                            } else {
                                @(Html.Kendo().Button()
                                .Name("greenalertbutton")
                                .ImageUrl(Url.Content("~/img/patient_alert_green.bmp"))
                                .HtmlAttributes(new { type = "button" })
                                .Events(ev => ev.Click("onAlertClick")))
                            }
                            }
 
<script>
    $(document).ready(function () {
        if ($@Model.IsClinicalAlert) {
            alert(@Model.ClinicalAlert);
            var wdw = $("#alertWindow").data("kendoWindow");
            wdw.open();
        }
    });
 
    function onAlertClick(e) {
        var wdw = $("#alertWindow").data("kendoWindow");
        wdw.open();
    }
</script>
@(Html.Kendo().Window()
    .Name("alertWindow")
    .Title("Clinical Alert")
    .Content(@<text><strong>@Model.ClinicalAlert</strong></text>)
    .Draggable()
    .Resizable()
    .Width(400)
    .Modal(true)
    .Visible(false)
    .Position(settings => settings.Top(150).Left(250)))
Dimiter Madjarov
Telerik team
 answered on 06 May 2014
1 answer
99 views
Is there any way to prevent the removal of an item from the select list when a user selects it and maintain the order of the select list?
Alexander Popov
Telerik team
 answered on 06 May 2014
3 answers
148 views
Hi guys, 
I don't know if I'm in the right section because my question is actually on datapager...but anyway..

I'd like to know if there any way to customize the appearance of the pager using mvc...
I remeber that in "normal" use I was able to set if to show pages number or just control or something like that..
I have the pager you see in the attached print, and I'd like to fix it so that it is rendered in just one line. (maybe removing page numbers, or showing just 5 instead of 10).

note that page size is set to 10 and has to remain like this.
Thanks
Fabio
Dimiter Madjarov
Telerik team
 answered on 06 May 2014
1 answer
181 views
Hi,

My search page showing list of employee in a grid and I want inline operation of grid.

My issue is :

Recently added data is not showing after "Save Changes" button clicked (It shows a copy of 1st record).
but  new data is appears after refresh button is clicked.

"Save change"  action is adding data perfectly.

Screenshot is attached 

Please see my code

cshtml
--------------------
@model TelerikMvc5App.ViewModel.EmployeeViewModel

@(Html.Kendo().Grid<TelerikMvc5App.ViewModel.EmployeeViewModel>()
    .Name("gridEmployee")
    .Columns(columns =>
    {
        columns.Bound(p => p.EmployeeId);
        columns.Bound(p => p.EmployeeName).Width(140);
        columns.Command(command => command.Destroy()).Width(110);
    })
    .ToolBar(toolbar =>
    {
        toolbar.Create();
        toolbar.Save();
    })
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Pageable(pageable => pageable
                .Refresh(true)
                .PageSizes(true)
                .ButtonCount(5))
    .Navigatable()
    .Filterable()
    .Sortable()
    .Scrollable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)
        .ServerOperation(false)
        .Events(events => events.Error("error_handler"))
            .Model(model => model.Id(p => p.EmployeeId))
            .Create("CreateEmp", "Employee", new { Area = "Employee" })
            .Read("SearchEmp", "Employee", new { Area = "Employee" })
            .Update("SaveEmp", "Employee", new { Area = "Employee" })
            .Destroy("DeleteEmp", "Employee", new { Area = "Employee" })
    )
)

<script type="text/javascript">
    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);
        }
    }
</script>


Controller
---------------------------------

 public static List<EmployeeViewModel> empList = new List<EmployeeViewModel>();


private List<EmployeeViewModel> GetAllEmployees()
        {           
            empList.Add(new EmployeeViewModel() { EmployeeId = 1, EmployeeName = "Kumar" });
            empList.Add(new EmployeeViewModel() { EmployeeId = 2, EmployeeName = "Jaysankar" });
            empList.Add(new EmployeeViewModel() { EmployeeId = 3, EmployeeName = "Sathish" });
            empList.Add(new EmployeeViewModel() { EmployeeId = 4, EmployeeName = "Koushik" });
            empList.Add(new EmployeeViewModel() { EmployeeId = 5, EmployeeName = "Ramesh" });            
            return empList;
        }

public ActionResult Search()
        {
            if (empList.Count == 0)
            {
                GetAllEmployees();
            }
            return View();
        }

 public ActionResult SearchEmp([DataSourceRequest]DataSourceRequest request)
        {
            return Json(empList.ToDataSourceResult(request));
        }

 [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult CreateEmp([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<EmployeeViewModel> emps)
        {
            foreach (EmployeeViewModel emp in emps)
            {               
                empList.Add(emp);
            }
        return Json(empList.ToDataSourceResult(request));
        }

 [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult SaveEmp([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<EmployeeViewModel> emps)
        {  
                foreach EmployeeViewModel emp in emps)
                {
                    // some code
                }            }
            return Json(empList.ToDataSourceResult(request));
        }

 [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult DeleteEmp([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<EmployeeViewModel> emps)
        {
            if (emps.Any())
            {
                foreach (EmployeeViewModel emp in emps)
                {
                    var item = empList.First(x => x.EmployeeId == emp.EmployeeId);
                    empList.Remove(item);
                }
            }            
            return Json(empList.ToDataSourceResult(request));
        }

--------------------------------------------------


Thanks
Kumar
Alexander Popov
Telerik team
 answered on 06 May 2014
6 answers
262 views
Here is our ImageBrowser startup code:

$("#Html").kendoEditor({
    imageBrowser: {
        schema: {
            model: {
                id: "EntFileId",
                fields: {
                    name: "name",
                    type: "type",
                    size: "size",
                    EntFileId: "EntFileId"
                }
            }
        },
        transport: {
            read: "@Url.Action("Index", "EditorImageBrowser", new { area = "" })",
            destroy: {
                url: "@Url.Action("Delete", "EditorImageBrowser", new { area = "" })",
                type: "POST"
            },
            create: {
                url: "@Url.Action("Create", "EditorImageBrowser", new { area = "" })",
                type: "POST"
            },
            uploadUrl: "@Url.Action("Upload", "EditorImageBrowser", new { area = "" })"
        }
    }
});


From our MVC Controller, we are returning this model of object to the Read action of our ImageBrowser:

return Json(new { name = "Test1.jpg", type = "f", size = 10000, EntFileId = "23ebf087-c946-4cb8-9f9c-f2584dd9aadc" });

When the Read action receives that result, it puts all of those properties, including the EntFileId, on the image item created in the ImageBrowser. So when I loop through the items in the ImageBrowser by doing something like this:

var data = $(".k-imagebrowser").data("kendoImageBrowser").dataSource.data();
$.each(data, function (key, obj) {
    console.log(obj);
    //displays: i {_events: Object, name: "Test1.jpg", size: 10000, type: "f", EntFileId: "23ebf087-c946-4cb8-9f9c-f2584dd9aadc"…}
});

You can see that the EntFileId gets attached to the items.

Now, when we Upload a file, we are supposed to return the uploaded file object back to Kendo, so we return it like this:

return Json(new { size = uploadedFileSize, name = file.Name, type = "f", EntFileId = file.FileId.ToString() }, "text/plain");

I see in Developer Tools that the Upload action is definitely returning an object with the EntFileId, but for some reason, when that item is put into the ImageBrowser, it does not attach the EntFileId property to that item. So after the Upload action completes, and I do the same loop through the items in the ImageBrowser, the uploaded image looks like this in the Console:

i {_events: Object, type: "f", name: "402082_546613141879_2009325815_n.jpg", size: 30834, uid: "0bd12e68-8245-48fe-81e1-d123fc813415"…}

There is no EntFileId property for the item (even if you expand the object).

Why does the extra EntFileId property get attached from the Read action, but not when the object is returned from the Upload action? Can you help me understand what's going on and why there is a difference? Thank you.
JohnVS
Top achievements
Rank 1
 answered on 05 May 2014
4 answers
157 views
Hello,

I have an ajax bound grid and I have it set to be sortable.  But when I click a column heading all of the data in the grid disappears.  If I switch it to server binding the sorting works.  I need ajax binding because I am using a client detail template.  What am I missing??

Here is the view:

@model IEnumerable<PASS.ViewModels.Proposals.IndexViewModel>
 
@{
    ViewBag.Title = "My Proposals";
}
 
<h2>My Proposals</h2>
 
<br />
<p>@Html.ActionLink("Create New Proposal", "Create", null, new { @class="link-button" })</p>
 
@(Html.Kendo().Grid(Model)
    .Name("Proposals")
    .Columns(columns =>
    {
        columns.Bound(m => m.ID).Title("Proposal ID");
        columns.Bound(m => m.Title).ClientTemplate("<a href='" + Url.Action("Update", "Proposals") + "/#= ID #'>" + "#= Title #" + "</a>");
        columns.Bound(m => m.ProposalType).Title("Proposal Type");
        columns.Bound(m => m.PI);
        columns.Bound(m => m.User_Facility_ID).Title("User Facility");       
    })
    .Sortable()
    .ClientDetailTemplateId("template")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id(m => m.ID))
        .Read(read => read.Action("Index", "Proposals"))
    ))
 
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().Grid<PASS.ViewModels.Proposals.TimeRequestsViewModel>()
        .Name("TimeRequests_#=ID#")
        .Columns(columns =>
        {
            columns.Bound(m => m.Cycle);
            columns.Bound(m => m.Status_Description).Title("Status");
        })
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("GetTimeRequests", "Proposals", new { proposalID = "#=ID#" }))
        )
        .Sortable()
        .ToClientTemplate()
)
</script>


Here are the relevant controller methods:

public ActionResult Index()
{
    int user_id = Convert.ToInt32(((Claim)((ClaimsIdentity)Thread.CurrentPrincipal.Identity).FindFirst(a => a.Type.Equals("UserID"))).Value);
 
    using (var context = new PASSEntities())
    {
        var vm = (from a in context.Proposals
                  join b in context.Proposal_Minions on a.ID equals b.Proposal_ID into j
                  from c in j.DefaultIfEmpty()
                  where (a.PI_User_ID == user_id || a.Creator_User_ID == user_id || (c.User_ID == user_id && c.Can_Read))
                  select new IndexViewModel()
                  {
                      ID = a.ID,
                      Title = a.Title,
                      ProposalType = a.Proposal_Types.Description,
                      PI_User_ID = a.PI_User_ID,
                      PI = (from d in context.Pools
                            join e in context.Users on d.ID equals e.Pool_ID
                            where e.ID == a.PI_User_ID
                            select d.First_Name + " " + d.Last_Name).FirstOrDefault(),
                      User_Facility_ID = a.User_Facility_ID
                  }).Distinct().OrderByDescending(a => a.ID).ToList();
 
        return View(vm);
    }
}
 
public ActionResult GetTimeRequests(int proposalID, [DataSourceRequest]DataSourceRequest request)
{
    using (var context = new PASSEntities())
    {
        var vm = (from a in context.Beamtime_Requests.ToList()
                  where a.Proposal_ID == proposalID
                  select new TimeRequestsViewModel()
                  {
                      ID = a.ID,
                      Proposal_ID = a.Proposal_ID,
                      Cycle = a.Cycle.Description + " " + a.Cycle.Year.ToString(),
                      Cycle_Requested_ID = a.Cycle_Requested_ID,
                      Status = a.Status,
                      Status_Description = a.Beamtime_Request_Statuses.Description
                  }).ToList();
 
        DataSourceResult result = vm.ToDataSourceResult(request);
        return Json(result, JsonRequestBehavior.AllowGet);
    }
}

Stephen
Top achievements
Rank 1
 answered on 05 May 2014
0 answers
207 views
Hi,

dropdown is not populating data while inline edit of grid
Search.cshtml
-------------
@model TelerikMvc5App.ViewModel.EmployeeViewModel
@(Html.Kendo().Grid<TelerikMvc5App.ViewModel.EmployeeViewModel>()
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.EmployeeId).Width(50);
        columns.Bound(p => p.EmployeeName).Width(140);
        columns.Bound(p => p.DateOfBirth).Width(100);
        columns.Bound(p => p.GenderId).Width(100);
        columns.Bound(p => p.MariatalStatusId).Width(110).EditorTemplateName("_MariatalStatusPartial").ClientTemplate("#:MariatalStatus#");
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
    })
         .ToolBar(toolbar => toolbar.Create())
        .Editable(editable => editable.Mode(GridEditMode.InLine))
                  .Selectable(s => s.Enabled(true)
                                    .Type(GridSelectionType.Row)
                                    .Mode(GridSelectionMode.Single))
    .Pageable(pageable => pageable
                .Refresh(true)
                .PageSizes(true)
                .ButtonCount(5))
    .Navigatable()
    .Filterable()
    .Sortable()
    .Scrollable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)
        .ServerOperation(false)
            .Events(events => events.Error("error_handler"))        
                   .Model(model =>
                    {
                        model.Id(p => p.EmployeeId);
                        model.Field(p => p.EmployeeId).Editable(false);
                        model.Field(p => p.MariatalStatusId);
                    })

            .Create("CreateEmp", "Employee", new { Area = "Employee" })
            .Read("SearchEmp", "Employee", new { Area = "Employee" })
            .Update("SaveEmp", "Employee", new { Area = "Employee" })
            .Destroy("DeleteEmp", "Employee", new { Area = "Employee" })
    )
)
<script type="text/javascript">  

    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);
        }
    }
</script>
--------------------
_MariatalStatusPartial.cshtml
----------------------------
@model TelerikMvc5App.ViewModel.EmployeeViewModel
@Html.Kendo().DropDownListFor(m => m.MariatalStatusId).DataTextField("Text").DataValueField("Value").DataSource(ds => ds.Read(r => { r.Action("GetMariatalStatus", "Employee", new { Area = "Employee" }); })).OptionLabel("Select Marital Status")


------------------
controller
-----------------------
 public ActionResult Search()
        {
            if (empList.Count == 0)
            {
                GetAllEmployees();
            }

            return View();
        }
 public JsonResult GetMariatalStatus()
        {
            List<SelectListItem> mariatalStatusList = new List<SelectListItem>();
            mariatalStatusList.Add(new SelectListItem { Text = "Single", Value = "1" });
            mariatalStatusList.Add(new SelectListItem { Text = "Married", Value = "2" });
            mariatalStatusList.Add(new SelectListItem { Text = "Others", Value = "3" });
            return Json(mariatalStatusList, JsonRequestBehavior.AllowGet);
        }

 private List<EmployeeViewModel> GetAllEmployees()
        {           
            empList.Add(new EmployeeViewModel() { EmployeeId = 1, EmployeeName = "Kumar", GenderId=1, MariatalStatusId=1 , MariatalStatus="Single" });
            empList.Add(new EmployeeViewModel() { EmployeeId = 2, EmployeeName = "Jaysankar", GenderId = 2, MariatalStatusId = 2, MariatalStatus = "Married" });
            empList.Add(new EmployeeViewModel() { EmployeeId = 3, EmployeeName = "Sathish" });
            empList.Add(new EmployeeViewModel() { EmployeeId = 4, EmployeeName = "Koushik" });
            empList.Add(new EmployeeViewModel() { EmployeeId = 5, EmployeeName = "Ramesh" });            
            return empList;
        }
------------

----------------
 public class EmployeeViewModel
    {
        public string EmployeeName { get; set; }
        public int? EmployeeId { get; set; }        
        
        public string LastName { get; set; }
        [Display(Name = "Gender")]
        [Required(ErrorMessage = "Gender is Required.")]
        public int GenderId { get; set; }
        [Display(Name = "Gender")]
        public string Gender { get; set; }

        [Display(Name = "Marital Status")]
        [Required(ErrorMessage = "Mariatal Status is Required.")]
        public int? MariatalStatusId { get; set; }

        [Display(Name = "Marital Status")]
        public string MariatalStatus { get; set; }

        [Display(Name = "Date Of Birth")]
        [Required(ErrorMessage = "Date Of Birth is Required.")]
        [DataType(DataType.Date)]      
        public DateTime? DateOfBirth { get; set; }
        
        [Display(Name = "Cell")]
        [Required(ErrorMessage = "Cell is Required.")]
        public string Cell { get; set; }


    }

Thanks
Kumar
Kumar Bharat
Top achievements
Rank 1
 asked on 05 May 2014
1 answer
175 views
Hello,

I'm a bit new to the MVC pattern and the Telerik ASP.NET MVC controls.  I've been working with ASP.NET Ajax for years now, but not the MVC stuff.  I finally had the opportunity to work on something MVC based, and find myself stuck already.  

I have a hierarchical menu driven by a stored procedure.  The procedure basically removes / disables items that a user doesn't have rights to based on a role and other information that's passed into the proc.  I'd like to implement its use in a partial view, but cant' for the life of me figure this out.  This may be more of a MVC question than a Menu specific question, but anyone can point me at an example that would be awesome.  

I've tried the sample applications generated by the Telerik template, but that uses a static menu in the _Layout file.  Not exactly what I want.

Thank you for your help!

Alex T.
Alex Gyoshev
Telerik team
 answered on 05 May 2014
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
Licensing
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?