This is a migrated thread and some comments may be shown as answers.

[Solved] Dynamic Grid MVC3 with GridCommandColumnSettings

1 Answer 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Neil Watts
Top achievements
Rank 1
Neil Watts asked on 20 Mar 2012, 08:11 PM
Hello All,

I am using a dynamically build Grid in my mvc 3 app. I am displaying it from a partial View.

I have set my GridColumnSettings up with no trouble. However; A few things I am struggling with.

1. If I add the GridCommandColumnSettings in my columns I get the error:
InvalidOperationException: Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.]
This is my Settings code
public static GridColumnSettings[] columns()
{
    GridColumnSettings[] columns = new[] 
        
            new GridCommandColumnSettings
            {
                Commands =
                {
                    new GridEditActionCommand(),
                    new GridDeleteActionCommand()
                },
                Width = "200px",
                Title = "Commands"
            },
            new GridColumnSettings { Member = "DeliveryID", Title = "DeliveryID", Visible = false},
            new GridColumnSettings { Member = "MarkAs", Title = "Mark_As_Delivered" },
            new GridColumnSettings { Member = "Priority", Title = "Priority"},
            new GridColumnSettings { Member = "Build", Title = "Build"},
            new GridColumnSettings { Member = "System", Title = "System_#"},
            new GridColumnSettings { Member = "DeliveryName", Title = "Delivery_Name"},
            new GridColumnSettings { Member = "Owner", Title = "Owner"},
            new GridColumnSettings { Member = "HostName", Title = "Host"},
            new GridColumnSettings { Member = "DeliveryType", Title = "Delivery_Type"},
            new GridColumnSettings { Member = "ShipTo", Title = "Ship_To"},
            new GridColumnSettings { Member = "DeliverTo", Title = "Deliver_To"},
            new GridColumnSettings { Member = "DeliveryNotes", Title = "Delivery_Notes"},
            new GridColumnSettings { Member = "Usage", Title = "Usage"},
            new GridColumnSettings { Member = "EstDate", Title = "Est.Date"},
            new GridColumnSettings { Member = "ActDate", Title = "Act.Date"},
            new GridColumnSettings { Member = "OrderNotes", Title = "Order_Notes"}
      };
    return columns;
 
}

I do not understand what that is saying.

2. I cant seem to find anywhere that shows how to add a ClientTemplate of type checkbox to the GridColumnSettings, is that possible and if so an example would be great.

3. How do I implement sorting etc. since this is a partial view?

Another thing, why cant my GridColumnSettings Title have a space in it?

ex
new GridColumnSettings { Member = "DeliveryName", Title = "Delivery Name"},
it will error on the Title.

Any help would be greatly appreciated.

Thanks

Squeal

1 Answer, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 05 Feb 2013, 03:05 PM
Hello

I came across this thread by searching for exactly the same Error:
InvalidOperationException: Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.

I cant figure out how to add a command button to grid columns as soon as i use GridColumnSettings
If i remove the commands, it works fine!
Did anyone ever find a solution for this?

Any help would be greatly appreciated.

Cheers


Tags
Grid
Asked by
Neil Watts
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Share this question
or