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
20
PivotGrid is not able to read data from the Model
posted

Hi,

Here is my "_IgniteRazorPivotTablePartial" View which is using IEnumerable<ModelName> model:

@using Infragistics.Web.Mvc
@model IEnumerable<ModelName>

<!DOCTYPE html>

<html>
<head>
<title></title>

<!-- Ignite UI Required Combined CSS Files -->
<link href="http://cdn-na.infragistics.com/igniteui/2014.2/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
<link href="http://cdn-na.infragistics.com/igniteui/2014.2/latest/css/structure/infragistics.css" rel="stylesheet" />

<script src="http://modernizr.com/downloads/modernizr-latest.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>

<!-- Ignite UI Required Combined JavaScript Files -->
<script src="http://cdn-na.infragistics.com/igniteui/2014.2/latest/js/infragistics.core.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/2014.2/latest/js/infragistics.lob.js"></script>
</head>
<body>
@(Html.Infragistics().PivotGrid()
.Width("915")
.Height("600")
.DataSourceOptions(
dataSourceOptions => dataSourceOptions
.Columns("[Location].[Location]")
.Rows("[Dates].[RequiredDate]")
.Measures("[Measures].[Freight]")
.FlatDataOptions(flatOptions => flatOptions.Metadata(
metadata => metadata.Cube(cube => cube.Name("Invoices").Caption("Invoices")
.MeasuresDimension(measuresDimension => measuresDimension.Caption("Measures").Measures(
measures =>
{
measures.AddMeasure().Name("Customers").Caption("Customers Count").Aggregator("$.ig.OlapUtilities.prototype.sumCount('Customers')");
}))
.Dimensions(dimensions =>
{
dimensions.AddDimension().Name("Customers").Caption("Customers").Hierarchies(
hierarchies =>
hierarchies.AddHierarchy().Name("Customers").Caption("Customers").Levels(levels =>
{
levels.AddLevel().Name("AllCustomers").Caption("All Customers")
.MemberProvider("function(item) {return 'All Customers'; }");
levels.AddLevel().Name("CustomerName").Caption("Customer Name")
.MemberProvider("function(item) {return item.CustomerName; }");
}));
dimensions.AddDimension().Name("Products").Caption("Products").Hierarchies(
hierarchies =>
hierarchies.AddHierarchy().Name("Products").Caption("Products").Levels(levels =>
{
levels.AddLevel().Name("AllProducts").Caption("All Products")
.MemberProvider("function(item) {return 'All Products'; }");
levels.AddLevel().Name("Product").Caption("Product")
.MemberProvider("function(item) {return item.ProductName; }");
}));
})))
.DataSource(Model)
.DataBind())).ID("pivotGrid")
.Render())

</body>
</html>

and here is my model:

public class ModelName
{
public string CustomerName { get; set; }
public string ProductName { get; set; }

}

And Controller:

public ActionResult ViewRazorIgnitePivotTable(string sessionId)
{
try
{
var ModelNameInstance = new List<ModelName>();
var fileName = Server.MapPath(@"~/sample.csv");

ModelNameInstance.AddRange(System.IO.File.ReadAllLines(fileName)
.Skip(1)
.Select(c => c.Split(','))
.Select(c => new ModelName
{
CustomerName = c[0].ToString(),
ProductName = c[1].ToString(),
}).ToList());

return PartialView("_IgniteRazorPivotTablePartial", ModelNameInstance);
}
catch (Exception ex)
{
throw ex;
}
}

My partial view, receives the right model (which I doubt is accepted by your Pivot Grid) so is not able to recognise neither item.ProductName nor item.CustomerName and throws an error which is unable to get value for null/undefined reference.

I appreciate if you could give me an idea of what could be the problem.

Thanks in advance,

Parents Reply Children
No Data