'JqGridColumnEditTypes Select' does not papulate data in Add/Edite form and Toolbar Search

Sep 13, 2013 at 4:33 PM
Hi,
I am just checking out your strongly Typed Helper. Now, I am just stuck on JqGridColumnEditTypes Select’ that does not populate any data. I am trying to replicate you Jqgrid sample.
<link href="@Url.Content("~/Content/site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.menubar.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/jqGrid/jquery-ui-jqgrid.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.8.2.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.9.0.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-menubar.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui.multiselect.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.tmpl.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.jqGrid.locale-en-4.4.1.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.jqGrid-4.4.1.min.js")" type="text/javascript"></script>
ViewModels :
namespace MvcApplication2.ViewModels
{
    [ModelBinder(typeof(ProductEditableViewModelBinder))]
    public class ProductFormEditableViewModel
    {
        #region Properties
        [JqGridColumnEditable(false)]
        public int Id { get; set; }

        [JqGridColumnEditable(true, EditType = JqGridColumnEditTypes.Text)]
        [StringLength(40)]
        [Required]
        public string Name { get; set; }

        [ScaffoldColumn(false)]
        [Required]
        public int SupplierId { get; set; }

        [JqGridColumnSortable(true, Index = "SupplierId")]
        [JqGridColumnEditable(true, "Suppliers", "Home", EditType = JqGridColumnEditTypes.Select)]
        [JqGridColumnFormatter("$.supplierFormatter", UnFormatter = "$.supplierUnFormatter")]
        [Required]
        public string Supplier { get; set; }

        [ScaffoldColumn(false)]
        [Required]
        public int CategoryId { get; set; }

        [JqGridColumnEditable(true, "Categories", "Home", EditType = JqGridColumnEditTypes.Select)]
        [Required]
        public string Category { get; set; }

        [DisplayName("Quantity Per Unit")]
        [JqGridColumnEditable(true, EditType = JqGridColumnEditTypes.Text)]
        [StringLength(20)]
        [Required]
        public string QuantityPerUnit { get; set; }

        [DisplayName("Unit Price")]
        [JqGridColumnFormatter(JqGridColumnPredefinedFormatters.Currency, DecimalPlaces = 2, DecimalSeparator = ".", Prefix = "$")]
        [JqGridColumnEditable(true, EditType = JqGridColumnEditTypes.Text)]
        [Range(0, Int32.MaxValue)]
        [Required]
        public decimal? UnitPrice { get; set; }

        [DisplayName("Units In Stock")]
        [JqGridColumnFormatter("$.unitsInStockFormatter", UnFormatter = "$.unitsInStockUnFormatter")]
        [JqGridColumnEditable(true)]
        [Range(0, 32767)]
        [Required]
        public short? UnitsInStock { get; set; }
        #endregion

        #region Constructor
        public ProductFormEditableViewModel()
        { }

        public ProductFormEditableViewModel(Product product)
        {
            this.Id = product.Id;
            this.Name = product.Name;
            this.SupplierId = product.SupplierId;
            this.Supplier = String.Format("[{0}] {1}", product.SupplierId, product.Supplier.Name);
            this.CategoryId = product.CategoryId;
            this.Category = product.Category.Name;
            this.QuantityPerUnit = product.QuantityPerUnit;
            this.UnitPrice = product.UnitPrice;
            this.UnitsInStock = product.UnitsInStock;
        }
        #endregion
    }
}
ProductEditableViewModelBinder : No change same as on sample code.

Grid construction :
@{
    ViewBag.Title = "jqGrid in ASP.NET MVC - CRUD [Form Editing]";

    var grid = new Lib.Web.Mvc.JQuery.JqGrid.JqGridHelper<MvcApplication2.ViewModels.ProductFormEditableViewModel>("products",
        dataType: Lib.Web.Mvc.JQuery.JqGrid.JqGridDataTypes.Json,
        methodType: Lib.Web.Mvc.JQuery.JqGrid.JqGridMethodTypes.Post,
        pager: true,
        rowsNumber: 10,
        sortingName: "Id",
        sortingOrder: Lib.Web.Mvc.JQuery.JqGrid.JqGridSortingOrders.Asc,
        url: Url.Action("Products"),
        viewRecords: true
    ).Navigator(new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorOptions() { Search = false },
        editActionOptions: new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorEditActionOptions() { Url = Url.Action("UpdateProduct") },
        addActionOptions: new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorEditActionOptions() { Url = Url.Action("InsertProduct") },
        deleteActionOptions: new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorDeleteActionOptions() { Url = Url.Action("DeleteProduct") }
    );
}
When i run the project only Supplier and Category not papulate data in dropdown.Requesting your guidance on where I might can go wrong. i am useing Lib.Web.Mvc 6.3.1
Sep 13, 2013 at 5:13 PM
myelearning wrote:
Hi,
I am just checking out your strongly Typed Helper. Now, I am just stuck on JqGridColumnEditTypes Select’ that does not populate any data. I am trying to replicate you Jqgrid sample.
<link href="@Url.Content("~/Content/site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.menubar.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/jqGrid/jquery-ui-jqgrid.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.8.2.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.9.0.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-menubar.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui.multiselect.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.tmpl.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.jqGrid.locale-en-4.4.1.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.jqGrid-4.4.1.min.js")" type="text/javascript"></script>
ViewModels :
namespace MvcApplication2.ViewModels
{
    [ModelBinder(typeof(ProductEditableViewModelBinder))]
    public class ProductFormEditableViewModel
    {
        #region Properties
        [JqGridColumnEditable(false)]
        public int Id { get; set; }

        [JqGridColumnEditable(true, EditType = JqGridColumnEditTypes.Text)]
        [StringLength(40)]
        [Required]
        public string Name { get; set; }

        [ScaffoldColumn(false)]
        [Required]
        public int SupplierId { get; set; }

        [JqGridColumnSortable(true, Index = "SupplierId")]
        [JqGridColumnEditable(true, "Suppliers", "Home", EditType = JqGridColumnEditTypes.Select)]
        [JqGridColumnFormatter("$.supplierFormatter", UnFormatter = "$.supplierUnFormatter")]
        [Required]
        public string Supplier { get; set; }

        [ScaffoldColumn(false)]
        [Required]
        public int CategoryId { get; set; }

        [JqGridColumnEditable(true, "Categories", "Home", EditType = JqGridColumnEditTypes.Select)]
        [Required]
        public string Category { get; set; }

        [DisplayName("Quantity Per Unit")]
        [JqGridColumnEditable(true, EditType = JqGridColumnEditTypes.Text)]
        [StringLength(20)]
        [Required]
        public string QuantityPerUnit { get; set; }

        [DisplayName("Unit Price")]
        [JqGridColumnFormatter(JqGridColumnPredefinedFormatters.Currency, DecimalPlaces = 2, DecimalSeparator = ".", Prefix = "$")]
        [JqGridColumnEditable(true, EditType = JqGridColumnEditTypes.Text)]
        [Range(0, Int32.MaxValue)]
        [Required]
        public decimal? UnitPrice { get; set; }

        [DisplayName("Units In Stock")]
        [JqGridColumnFormatter("$.unitsInStockFormatter", UnFormatter = "$.unitsInStockUnFormatter")]
        [JqGridColumnEditable(true)]
        [Range(0, 32767)]
        [Required]
        public short? UnitsInStock { get; set; }
        #endregion

        #region Constructor
        public ProductFormEditableViewModel()
        { }

        public ProductFormEditableViewModel(Product product)
        {
            this.Id = product.Id;
            this.Name = product.Name;
            this.SupplierId = product.SupplierId;
            this.Supplier = String.Format("[{0}] {1}", product.SupplierId, product.Supplier.Name);
            this.CategoryId = product.CategoryId;
            this.Category = product.Category.Name;
            this.QuantityPerUnit = product.QuantityPerUnit;
            this.UnitPrice = product.UnitPrice;
            this.UnitsInStock = product.UnitsInStock;
        }
        #endregion
    }
}
ProductEditableViewModelBinder : No change same as on sample code.

Grid construction :
@{
    ViewBag.Title = "jqGrid in ASP.NET MVC - CRUD [Form Editing]";

    var grid = new Lib.Web.Mvc.JQuery.JqGrid.JqGridHelper<MvcApplication2.ViewModels.ProductFormEditableViewModel>("products",
        dataType: Lib.Web.Mvc.JQuery.JqGrid.JqGridDataTypes.Json,
        methodType: Lib.Web.Mvc.JQuery.JqGrid.JqGridMethodTypes.Post,
        pager: true,
        rowsNumber: 10,
        sortingName: "Id",
        sortingOrder: Lib.Web.Mvc.JQuery.JqGrid.JqGridSortingOrders.Asc,
        url: Url.Action("Products"),
        viewRecords: true
    ).Navigator(new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorOptions() { Search = false },
        editActionOptions: new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorEditActionOptions() { Url = Url.Action("UpdateProduct") },
        addActionOptions: new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorEditActionOptions() { Url = Url.Action("InsertProduct") },
        deleteActionOptions: new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorDeleteActionOptions() { Url = Url.Action("DeleteProduct") }
    );
}
When i run the project only Supplier and Category not papulate data in dropdown.Requesting your guidance on where I might can go wrong. i am useing Lib.Web.Mvc 6.3.1
Solved :-) ... Lib.Web.Mvc is gr8 ... thank you !!
Coordinator
Sep 13, 2013 at 6:41 PM
myelearning wrote:
Solved :-) ... Lib.Web.Mvc is gr8 ... thank you !!
I'm happy to hear that :).