Click here to Skip to main content
13,042,630 members (79,501 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I'm must create a nopCommerce plugin to implement some telerik gird with a dropdownlist as editable rows, the problem is that the plugin is a Class Library, not a ASP.NET MVC application and the Routing is done manually in a RouteProvider.cs file. So I folowed the example here: And must have the following configuration:
My Model:
    public class ContentModel : BaseNopModel
    public string ContentId { get; set; }
    public string Title { get; set; }
    public string Content { get; set; }
    [UIHint("DiscountsEditor"), Required]
    public string Discounts { get; set; }

My Controller:
public ActionResult _SelectAjaxEditing()
    List<ContentModel> model = new List<ContentModel>();
    return View("Nop.Plugin.Widgets.DiscountBanner.Views.WidgetsDiscountBanner.Configure", _discountBannerSettings.contentGrid == "" || _discountBannerSettings.contentGrid == null ? new GridModel(model) : new GridModel(JsonHelper.JsonDeserialize<List<ContentModel>>(_discountBannerSettings.contentGrid)));

My View:
        Layout = "";
    @model Nop.Plugin.Widgets.DiscountBanner.Models.ConfigurationModel
    @using Nop.Plugin.Widgets.DiscountBanner.Models;
    @using Nop.Web.Framework;
    @using Telerik.Web.Mvc.UI;
    @using Nop.Services.Discounts;
<script type="text/javascript">
    function onEdit(e) {
        $(e.form).find('#Discounts').data('tDropDownList').select(function (dataItem) {
            return dataItem.Value == e.dataItem['Text'];
    <table class="adminContent">
        <td class="adminTitle" colspan="2">
            DiscountBanner Plugin for sing-up and sales tracking script implementation on your site
        <td class="adminTitle">
                @Html.NopLabelFor(model => model.ZoneId):
        <td class="adminData">
                @Html.DropDownListFor(model => model.ZoneId, Model.AvailableZones)
                @Html.ValidationMessageFor(model => model.ZoneId)
        <td class="adminTitle" colspan="2">
            .DataKeys(keys =>
                    keys.Add(model => model.ContentId);
            .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Text).ImageHtmlAttributes(new { style = "margin-left:0" }))
            .DataBinding(dataBinding =>
                        .Select("_SelectAjaxEditing", "WidgetsDiscountBanner")
                        .Insert("_InsertAjaxEditing", "WidgetsDiscountBanner")
                        .Update("_SaveAjaxEditing", "WidgetsDiscountBanner")
                        .Delete("_DeleteAjaxEditing", "WidgetsDiscountBanner");
            .Columns(columns =>
                    columns.Bound(c => c.Title);
                    columns.Bound(c => c.Content);
                    columns.Bound(c => c.Discounts);
                    columns.Command(commands =>
                .ClientEvents(events => events.OnEdit("onEdit"))

And My custom View "DiscountsEditor.cshtml":

@using Telerik.Web.Mvc.UI;
@using Nop.Services.Discounts;
    var _discountService = Nop.Core.Infrastructure.EngineContext.Current.Resolve<IDiscountService>();
    var discounts = _discountService.GetAllDiscounts(null, true);
    List<SelectListItem> listDiscounts = new List<SelectListItem>();
    foreach (var item in discounts)
        listDiscounts.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() });

From what could I tell is that telerik doesn't find my partial view DiscountsEditor.cshtml because the project is a class library and the route values are not the same, for the specific project I must make my views "Embedded Resource" so I can call them with the full name, the problem is that I can't configure Telerik Grid to use a partial view from somewhere else.

I tried to use a custom template like this:

columns.Bound(c => c.Discounts)

But the template loads after I put some information in the grid and is not editable, if I want to edit it the dropdownlist transforms into a TextBox, I don't know what to do next, or if I can use another controller but to load the dropdown from the current view not a partial view.

Posted 18-Jun-13 23:16pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hi ,
Did you find Solution for your problem ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 24 Jan 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100