rauhryan
3/15/2010 - 9:29 PM

gistfile1.cs

    public class GridAction
    {
        public GridModel Execute(GridModel input)
        {
            return input;
        }

        public jqGridModel DataQuery(GridRequest request)
        {
            var invoices = new[]
                               {
                                   new Invoice()
                                       {Amount = 100, Id = 1, InvoiceDate = DateTime.Now, Note = "some notes", Tax = 2},
                                        new Invoice()
                                       {Amount = 100, Id = 2, InvoiceDate = DateTime.Now, Note = "some notes", Tax = 2},
                                        new Invoice()
                                       {Amount = 100, Id = 3, InvoiceDate = DateTime.Now, Note = "some notes", Tax = 2},
                                        new Invoice()
                                       {Amount = 100, Id = 4, InvoiceDate = DateTime.Now, Note = "some notes", Tax = 2},
                                        new Invoice()
                                       {Amount = 100, Id = 5, InvoiceDate = DateTime.Now, Note = "some notes", Tax = 2},
                                        new Invoice()
                                       {Amount = 100, Id = 6, InvoiceDate = DateTime.Now, Note = "some notes", Tax = 2},
                                        new Invoice()
                                       {Amount = 100, Id = 7, InvoiceDate = DateTime.Now, Note = "some notes", Tax = 2}
                               };

            var rows = (from i in invoices
                        select new { id = i.Id, cell = new[]{ i.Id.ToString(),i.InvoiceDate.ToShortDateString(),i.Amount.ToString(),i.Tax.ToString(), i.Total.ToString(),i.Note}}
                                ).ToJson();

            return new jqGridModel() { page = 1, records = rows.Length, rows = rows, total = 1 };
        }
    }

    public class GridRequest
    {
    }

    public class Grid : FubuPage<GridModel> { }

    public class GridModel
    {
    }

    public class jqGridModel
    {
        public int page { get; set; }
        public int total { get; set; }
        public int records { get; set; }
        public string rows { get; set; }
    }

    public class Invoice
    {
        public int Id { get; set; }
        public DateTime InvoiceDate { get; set; }
        public double Amount { get; set; }
        public double Tax { get; set; }
        public double Total
        {
            get
            {
                return Amount + Tax;
            }
        }
        public string Note { get; set; }
    }