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

Editable Grid - add command columns

7 Answers 413 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.
brandon
Top achievements
Rank 1
brandon asked on 20 Feb 2010, 10:12 PM
I'm using VS2010 RC with ASP.NET MVC 2 RC 2. I'm following the example of the editable grid.  Any time I try to add this:
columns.Command(commands => 
  commands.Edit(); 
  commands.Delete(); 
}); 

I get this error:

Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.


Suggestions?



7 Answers, 1 is accepted

Sort by
0
brandon
Top achievements
Rank 1
answered on 20 Feb 2010, 10:38 PM
I seem to have narrowed it down to having my grid's .DataKey set to an int value.  It only seems to work if I make my ID property on my model a string.  I assume that is a bug.
0
Niels Schneider
Top achievements
Rank 1
answered on 20 Feb 2010, 11:03 PM
I have the same problem.
0
Wade
Top achievements
Rank 1
answered on 21 Feb 2010, 04:13 PM
ditto. Same thing here.  I'll live with it being a string for now, but I did have to scratch my head.  Thank you google and thank you previous posters :)
0
Muhammad Jamil Nawaz
Top achievements
Rank 2
answered on 22 Feb 2010, 08:55 AM
I have the same problem. I am using Latest Beta of Telerik MVC Extentions and ASP.NET MVC RC 1. Whenever I try to add command column its giving this error and without that it works. But strange thing is, i setup the telerik examples project on my PC and those examples are working fine. I am wondering what is causing this issue?

Any idea??

Thanks!
JAMIL
0
Atanas Korchev
Telerik team
answered on 22 Feb 2010, 04:44 PM
Hello guys,

Unfortunately this problem was not caught before the release. Since there is no simple way to fix it I have attached a patched version which contains this as well a few other fixes.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
christian
Top achievements
Rank 1
answered on 07 Nov 2010, 06:43 PM
This is still tru for release 2010.2 ? I get

The model item passed into the dictionary is of type 'System.Int32', but this dictionary requires a model item of type 'System.String'.



And the datakey is a int
0
bata
Top achievements
Rank 1
answered on 08 Feb 2011, 11:11 PM
I have the same problem again, but with the latest Telerik MVC 201031381, MVC2.dll.

        columns.Template(oi =>
                                              {%>
    <%=
                                                      Html.Telerik().NumericTextBoxFor(item => oi.ReturnQuantity).AssetKey("ReturnQuantity_" + oi.OrderItemId).
                                                                                     DecimalDigits(2).EmptyMessage(Server.HtmlDecode(Html.T("QuantityToReturnValidationMsg"))).MinValue(0).MaxValue(
                                                                   oi.Quantity).IncrementStep((oi.Quantity - Math.Floor(oi.Quantity) > 0 ? (decimal)0.1 : 1)).Value(oi.Quantity).Name("QuantityToReturn_" + oi.OrderItemId).InputHtmlAttributes( new {style = "width:60px"}).
                                                          ToHtmlString()%>
                                                         
%>
    <%
                                              })
                             .Title(Server.HtmlDecode(Html.T("QuantityEdit"))).Width(25).HtmlAttributes(
                                 new {style = "text-align:center"})
                                 .ClientTemplate(Html.Telerik().NumericTextBoxFor(x=>(double)(Convert.ToDecimal("<#=ReturnQuantity#>"))).AssetKey("ReturnQuantity_<#=OrderItemId#>").
                                                                                     DecimalDigits(2).EmptyMessage(Server.HtmlDecode(Html.T("QuantityToReturnValidationMsg"))).MinValue(0).MaxValue((double)(Convert.ToDecimal("<#=Quantity#>"))).IncrementStep((double)((double)(Convert.ToDecimal("<#=Quantity#>")) - Math.Floor((double)(Convert.ToDecimal("<#=Quantity#>"))) > 0 ? (decimal)0.1 : 1)).Value((double)(Convert.ToDecimal("<#=Quantity#>"))).Name("QuantityToReturn_<#=OrderItemId#>").InputHtmlAttributes( new {style = "width:60px"}).ToHtmlString()
    )

Error is being returned pointing to Template in this case, not to Client Template.
Any suggestion?
Tags
Grid
Asked by
brandon
Top achievements
Rank 1
Answers by
brandon
Top achievements
Rank 1
Niels Schneider
Top achievements
Rank 1
Wade
Top achievements
Rank 1
Muhammad Jamil Nawaz
Top achievements
Rank 2
Atanas Korchev
Telerik team
christian
Top achievements
Rank 1
bata
Top achievements
Rank 1
Share this question
or