powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Проблемы с Trirand grid
1 сообщений из 1, страница 1 из 1
Проблемы с Trirand grid
    #38612857
kim-kong
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Пробую пользоваться их гридом, но во вью нифига не отображается. Что я делаю не так ?

модель
Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
public class PivotJqGridModel
    {
        public JQGrid PivotGrid { get; set; }

        public PivotJqGridModel()
        {
            PivotGrid = new JQGrid
            {
                Columns = new List<JQGridColumn>()
                                 {                                    
                                     new JQGridColumn { DataField = "ArticleId", Width = 150 },
                                     new JQGridColumn { DataField = "IngListId", Width = 150 },
                                     new JQGridColumn { DataField = "ProdId", Width = 150 },
                                     new JQGridColumn { DataField = "IngId", Width = 150 },
                                     new JQGridColumn { DataField = "ProdName", Width = 150 },
                                     new JQGridColumn { DataField = "IngName", Width = 150 },
                                     new JQGridColumn { DataField = "Amount", Width = 150 },
                                     new JQGridColumn { DataField = "Percent", Width = 150 },
                                     new JQGridColumn { DataField = "losses", Width = 150 },
                                     new JQGridColumn { DataField = "total_losses", Width = 150 },
                                     new JQGridColumn { DataField = "reporting_losses", Width = 150 },
                                     new JQGridColumn { DataField = "total_reporting_losses", Width = 150 }
                                 },
                Width = Unit.Pixel(650),
                Height = Unit.Pixel(200)
            };
        }
    }



Контроллер
Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
public ActionResult PivotMultipleAggregates()
            {
                var gridModel = new PivotJqGridModel();
                var grid = gridModel.PivotGrid;         
                grid.DataUrl = Url.Action("PivotMultipleAggregates_DataRequested");
                SetUpGrid_PivotMultipleAggregates(grid);
                return View(gridModel);
            }

            public JsonResult PivotMultipleAggregates_DataRequested(int id)
            {
                // Get both the grid Model and the data Model
                // The data model in our case is an autogenerated linq2sql database based on Northwind.
                var gridModel = new PivotJqGridModel();
                var db = new EnzoDatabaseEntities1();
                var sum = db.IngLists.Where(x => x.ArticleId == id).Sum(x => (float?)x.amount);

                IQueryable query = from il in db.IngLists
                     join a in db.Articles on il.ArticleId equals a.Id
                     join p in db.Products on a.ProductId equals p.Id
                     join g in db.Goods on il.GoodId equals g.Id
                     where (a.Id == id) && (il.GoodId == g.Id)
                     select new
                     {
                         ArticleId = a.Id,
                         IngListId = il.Id,
                         ProdId = id,
                         ProdName = p.Name,
                         IngName = g.Name,
                         Amount = il.amount,
                         Percent = il.amount * 100 / sum,
                         losses = il.losses,
                         reporting_losses = il.reporting_losses,
                         total_losses = il.losses * il.amount / 100,
                         total_reporting_losses = il.reporting_losses * il.amount / 100,
                         sum = sum
                     };
                SetUpGrid_PivotMultipleAggregates(gridModel.PivotGrid);
                return gridModel.PivotGrid.DataBind(query);
            }

            public void SetUpGrid_PivotMultipleAggregates(JQGrid grid)
            {
                var pivot = grid.PivotSettings;
                pivot.RowTotals = true;
                pivot.ColTotals = true;
                pivot.FrozenStaticCols = true;
                pivot.GroupSummaryPosition = GroupSummaryPosition.Footer;
                pivot.XDimension.Add(new PivotDimension { DataName = "ProdName" });
                pivot.XDimension.Add(new PivotDimension { DataName = "IngName" });
                pivot.Aggregates.Add(new PivotAggregate
                {
                    Member = "Amount",
                    Aggregator = PivotAggregator.Sum,
                    Width = 80,
                    Label = "Amount",
                    GroupSummaryType = GroupSummaryType.Sum,
                    Formatter = PivotFormatter.Number,
                    Align = Trirand.Web.Mvc.TextAlign.Right
                });
                pivot.Aggregates.Add(new PivotAggregate
                {
                    Member = "Percent",
                    Aggregator = PivotAggregator.Sum,
                    Width = 80,
                    Label = "Percent",
                    GroupSummaryType = GroupSummaryType.Sum,
                    Formatter = PivotFormatter.Number,
                    Align = Trirand.Web.Mvc.TextAlign.Right
                });


                grid.PagerSettings.PageSize = 10;
                grid.Height = Unit.Pixel(300);
                grid.Width = Unit.Pixel(800);

            }



Вью
Код: html
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
@{
    ViewBag.Title = "PivotMultipleAggregates";
}
@model EnzoApplication.Models.PivotJqGridModel
@using Trirand.Web.Mvc

    <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.0/themes/redmond/jquery-ui.css" />
    <link rel="stylesheet" type="text/css" href="../../Content/themes/Site.css" />    
    <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/i18n/grid.locale-en.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery.jqGrid.min.js"></script>       

    <div>
        @Html.Trirand().JQGrid(Model.PivotGrid, "PivotGrid")
    </div>
...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Проблемы с Trirand grid
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]