Hello.
I am using 2012.2 and MVC4.
My model has members for CustomerName, CustomerStreet, CustomerCity, CustomerState, and CustomerZip.
I want to display one column in my igGrid that would show CustomerName, CustomerStreet on a new line, CustomerCity/State/Zip concatenated together on a new line.
I've read a few posts, blogs, etc., and still can't figure it out.
Below is my grid definition as it stands.
Thanks in advance,
Mike
@(Html.Infragistics().Grid(Model.Sales.AsQueryable()) .PrimaryKey("OrderNumber") .AutoGenerateLayouts(true) .Width("100%") .DataBind() .Features(features => { features.Sorting().Type(OpType.Local); features.ColumnMoving().MoveType(MovingType.Dom); features.Selection().Mode(SelectionMode.Row); features.Filtering().Type(OpType.Local); }) .AutoGenerateColumns(false) .Columns(column => { column.For(x => x.OrderNumber).HeaderText("OrderNumber").DataType("int32"); // COLUMN FOR CUSTOMER INFO }) .Render() )
That looks a lot better.
Thank you.
Hello,
The another approach you can use is column template feature. You will find more details on sample and document on this on the below links:
http://help.infragistics.com/NetAdvantage/jQuery/2012.2/CLR4.0?page=Creating a Basic Column Template in the igGrid.html
http://ko.infragistics.com/products/jquery/sample/grid/basic-column-template
I hope this helps.
Ok, after fiddling a bit more I came up with this. Is there a better way?
@(Html.Infragistics().Grid(Model.Sales.AsQueryable()) .PrimaryKey("OrderNumber") .Width("100%") .Height("500px") .DataBind() .Features(features => { features.Sorting().Type(OpType.Local); features.ColumnMoving().MoveType(MovingType.Dom); features.Selection().Mode(SelectionMode.Row); features.Filtering().Type(OpType.Local); }) .AutoGenerateColumns(false) .Columns(column => { column.For(x => x.AccountNumber).HeaderText("Account#").DataType("int32").Width("160px"); column.For(x => x.OrderNumber).HeaderText("Order#").DataType("int32").Width("160px"); column.For(x => x.LedgerType).HeaderText("Type").DataType("string").Width("80px"); column.For(x => x.Created).HeaderText("Created").DataType("date").Format("MM/dd/yyyy").Width("160px"); column.For(x => x.Completed).HeaderText("Completed").DataType("date").Format("MM/dd/yyyy").Width("160px"); column.For(x => x.StatusText).HeaderText("Status").DataType("string"); column.For(x => x.HoldStatus).HeaderText("Hold Status").DataType("string"); column.For(x => x.CustomerName).DataType("string").Hidden(true); column.For(x => x.CustomerStreet).DataType("string").Hidden(true); column.For(x => x.CustomerCity).DataType("string").Hidden(true); column.For(x => x.CustomerState).DataType("string").Hidden(true); column.For(x => x.CustomerZip).DataType("int64").Hidden(true); column.Unbound("CustInfo").HeaderText("Customer Info").DataType("string").Formula("cInfo").Width("250px"); }) .Render() ) <script> function cInfo(row, grid) { return row.CustomerName + "<br/>" + row.CustomerStreet + "<br />" + row.CustomerCity + ", " + row.CustomerState + " " + row.CustomerZip; } </script>