Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Help for webgrid
posted

I am beginner in asp.net mvc3

i want to create a grid view using jquery grid of infragistics grid

but have a problem in view grid is not create corresponding model

model:

using System;
using System.Linq;
using System.Collections.Generic;
public class BankAccount
{
    public int AccountNumber { get; set; }
    public string AccountName { get; set; }
    public DateTime AccountDate { get; set; }
    public string AccountType { get; set; }
    public decimal AccountBalance { get; set; }
}
public class AccountModels
{
    public static IQueryable<BankAccount> GetAccountList()
    {
        List<BankAccount> accountList = new List<BankAccount>();
        DateTime date = DateTime.Now;
        for (int i = 1; i < 1001; i++)
        {
            accountList.Add(new BankAccount()
            {
                AccountNumber = i,
                AccountName = "Test" + i.ToString(),
                AccountDate = date,
                AccountType = "chk",
                AccountBalance = 12345678.90M
            }
            );
        }
        return accountList.AsQueryable<BankAccount>();
    }
}

 

View:

@using Infragistics.Web.Mvc;
@using Messmanagement.Models;
@{
    ViewBag.Title = "MealEntry";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>MealEntry</h2>

    @( Html.Infragistics().Grid<BankAccount>()
        .ID("igGrid1") 
        .Columns(column =>
        { 
            column.For(x => x.AccountNumber).DataType("int").HeaderText("Account Number"); 
            column.For(x => x.AccountName).DataType("string").HeaderText("Account Name"); 
            column.For(x => x.AccountDate).DataType("date").HeaderText("Account Date"); 
            column.For(x => x.AccountType).DataType("string").HeaderText("Account Type"); 
            column.For(x => x.AccountBalance).DataType("number").HeaderText("Account Balance"); 
        }) 
        .Features(features => 
        { 
            features.Paging().PageSize(20).PrevPageLabelText("Previous").NextPageLabelText("NEXT"); 
            features.Sorting().Mode(SortingMode.Single).ColumnSettings(settings => 
            { 
                settings.ColumnSetting().ColumnKey("AccountNumber").AllowSorting(true); 
     
            }); 
            features.Selection().MouseDragSelect(true).MultipleSelection(true).Mode(SelectionMode.Row); 
        }) 
        .ClientDataSourceType(ClientDataSourceType.JSON) 
        .DataSourceUrl(Url.Action("GetAccountList"))
        .Width("100%") 
        .Height("350") 
        .LocalSchemaTransform(true) 
        .DataBind() 
        .Render()   
    )

Controller:

 public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        [GridDataSourceAction]
        public ActionResult GetAccountList()
        {
            return View(Models.AccountModels.GetAccountList());
        }

    }

any one can help please reply.

Thank you

Parents
  • 8421
    posted

    Hello,

    As far as I can see your code seems to be fine.  I took your logic, placed it in to an application, and then it compiled and ran for me without any issues.  I have attached the sample project I used to test this.  Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.

    Please note that my test was performed using version 11.1.20111.2030 in NetAdvantage for jQuery 2011 Vol. 1.

    Please let me know if I can provide any further assistance.

    GridModelTest.zip
Reply Children
No Data