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