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
1465
How to "compute" column MVC
posted

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()
    )
Parents
  • 1465
    Suggested Answer
    posted

    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>
Reply Children
No Data