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
1010
Error in using Infragistics.Web.Mvc 5.15.2.2081
posted

This is an example I downloaded from Infragistics forum.

I'm seeing this odd behavior in using 2015.2 version of TreeGrid. When I use Infragistics.Web.Mvc version 5.15.2.2081, it gives me a null exception, but when I use Infragistics.Web.Mvc 5.15.1.1005 it works. 

I'm pasting the code here because I'm unable to upload my solution files. It is giving me page not found error when I hit save button on upload files dialog. I'm using Chrome. 

Views\Home\Index.cshtml

@using Infragistics.Web.Mvc
@model IQueryable<WebApplication8.Models.Product>
@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>

<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>
<script src="http://cdn-na.infragistics.com/igniteui/2015.2/latest/js/infragistics.loader.js"></script>

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

<!-- Ignite UI Required Combined JavaScript Files -->
<script src="http://cdn-na.infragistics.com/igniteui/2015.2/latest/js/infragistics.core.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/2015.2/latest/js/infragistics.dv.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/2015.2/latest/js/infragistics.lob.js"></script>
</head>
<body>
@(Html.Infragistics()
.TreeGrid(Model)
.ID("grid1")
.PrimaryKey("IDProjeto")
.ForeignKey("CategoryID")
.ForeignKeyRootValue(0)
.AutoGenerateColumns(false)
.InitialExpandDepth(1)
.Columns(col =>
{
col.For(c => c.IDProjeto).HeaderText("ProductID").Hidden(false);
col.For(c => c.Name).HeaderText("Name");
col.For(c => c.ReleaseDate).HeaderText("ReleaseDate");
col.For(c => c.CategoryID).HeaderText("Category");
col.For(c => c.ProductNumber).HeaderText("Product Number");
})

.DataBind()
.Render())

</body>
</html>

Models\Product.cs

public class Product

{
public int IDProjeto { get; set; }
public string Name { get; set; }
public string ProductNumber { get; set; }
public DateTime ReleaseDate { get; set; }
public string Category { get; set; }

public int CategoryID { get; set; }
//public Category Category { get; set; }

}

Controllers\HomeController.cs

public class HomeController : Controller
{
//
// GET: /Home/

public ActionResult Index()
{
return View(this.GetProducts().AsQueryable());
}

private List<Product> GetProducts()
{
List<Product> products = new List<Product>()
{
new Product() { IDProjeto = 1, Name = "Adjustable Race", ProductNumber = "AR-5381", CategoryID = 0 },
new Product() { IDProjeto = 2, Name = "Bearing Ball", ProductNumber = "BA-8327", CategoryID = 0 },
new Product() { IDProjeto = 3, Name = "BB Ball Bearing", ProductNumber = "BE-2349", CategoryID = 2 },
new Product() { IDProjeto = 4, Name = "Headset Ball Bearings", ProductNumber = "BE-2908", CategoryID = 2 },
new Product() { IDProjeto = 316, Name = "Blade", ProductNumber = "BL-2036", CategoryID = 3},
new Product() { IDProjeto = 317, Name = "LL Crankarm", ProductNumber = "CA-5965", CategoryID = 3 },
new Product() { IDProjeto = 318, Name = "ML Crankarm", ProductNumber = "CA-6738", CategoryID = 3 },
new Product() { IDProjeto = 319, Name = "HL Crankarm", ProductNumber = "CA-7457", CategoryID = 3 },
new Product() { IDProjeto = 320, Name = "Chainring Bolts", ProductNumber = "CB-2903", CategoryID = 2 },
new Product() { IDProjeto = 321, Name = "Chainring Nut", ProductNumber = "CN-6137", CategoryID = 2 }
};

return products;
}

public void SaveData()
{
GridModel model = new GridModel();
List<Transaction<Product>> products = model.LoadTransactions<Product>(Request.Form["ig_transactions"]);
}
}

  • 29417
    Offline posted

    Hello C R , 

    Thank you for posting in our forum. 

    Based on the code snippets what seems to be missing is the setting for the ChildDataKey option.

    The ChildDataKey should be set to the name of a property in the model of type Queryable ( this property will then be populated to create a hierarchical structure).

    So for example the model can look like this:

     

    public class Product

     

    {

     public int IDProjeto { get; set; }

     public string Name { get; set; }

     public string ProductNumber { get; set; }

     public DateTime ReleaseDate { get; set; }

     public string Category { get; set; }

     

    public int CategoryID { get; set; }

     public List<Category> Categories { get; set; } 

    }

     

    And the ChildDataKey can be set to “Categories”.

     

    Let me know if setting the option solves your issue.

     

    Best Regards,

    Maya Kirova

    Infragistics, Inc.

    http://es.infragistics.com/support