This is a migrated thread and some comments may be shown as answers.
Grid with dynamic ajax binding and Column filter issue
5 Answers 101 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ravindra
Top achievements
Rank 1
Ravindra asked on 26 Apr 2011, 02:34 PM
Hi,
I'm trying to use the MVC grid with dynamic type and Ajax binding. it is working fine until i enable the filterable option enabled in the grid.
When i enable the filter option in the grid, the default filter dropdown has no operators populated in it. below is the code that i have been using and attached a sample screenshot of how the default filter is looking like

Html.Telerik().Grid<dynamic>()
    .Name("Grid")
    .Columns(columns =>
    {
        if (context.Columns != null)
        {
            foreach (ColumnSettings item in context.Columns)
            {
                columns.Bound(item.Key).Title(item.Header).Filterable(item.Filterble).Sortable(item.Sortable);
            }
        }
        else
        {
            columns.AutoGenerate(true);
        }
    })
    .DataBinding(dataBinding => dataBinding.Ajax().Select("_AjaxBinding", "Grid"))
    .Pageable(paging => paging.Enabled(config.IsPagable))
    .Sortable(sorting => sorting.Enabled(config.IsSortable))
    .Filterable(filter => filter.Enabled(config.IsFilterable))
    .Groupable(grouping => grouping.Enabled(config.IsGroupable))

in the above code, you will see 'config' instance. this i'm using it for some configuration purpose. please see the attachment and help me resolving this issue

Thanks in advance!
Ravindra
than

5 Answers, 1 is accepted

Sort by
0
Ravindra
Top achievements
Rank 1
answered on 29 Apr 2011, 03:56 AM

This got resolved by specifying the column type as below


columns.Bound(typeof(decimal), Key)

0
alonav
Top achievements
Rank 1
answered on 24 May 2011, 04:12 PM
Hi,
I tried to implement the grid with dynamic and it works fine but i still have 2 issues:
issue 1:
i use GridEditMode.InLine for edit and i need to add a key for edit.
when i add it like this:

.DataKeys(keys => { keys.Add(

 

"UnitId"); })

 


i get:
 

Server Error in '/' Application.

'object' does not contain a definition for 'UnitId'

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'object' does not contain a definition for 'UnitId'

Source Error:

Line 62: }          
Line 63: 
Line 64: @(Html.Telerik().Grid<dynamic>()Line 65:        .Name("Grid")
Line 66:           .DataKeys(keys => { keys.Add("UnitId"); })

Source File: c:\GreenroadTech\Applications\Main\GRT.MVC\GRT.MVC\Views\Activities\Index.cshtml    Line: 64

Stack Trace:

[RuntimeBinderException: 'object' does not contain a definition for 'UnitId']
   CallSite.Target(Closure , CallSite , Object ) +216
   System.Dynamic.UpdateDelegates.UpdateAndExecute1(CallSite site, T0 arg0) +940
   lambda_method(Closure , Object ) +64
   Telerik.Web.Mvc.UI.GridDynamicDataKey.GetValue(Object dataItem) +15
   System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) +250
   Telerik.Web.Mvc.UI.GridDataKeyStore.GetDataKeyValues(Object dataItem) +204
   Telerik.Web.Mvc.UI.Html.GridHtmlHelper`1.HiddenForDataKey(Object dataItem) +101
   Telerik.Web.Mvc.UI.Html.GridButtonBuilder.Create(Object dataItem) +109
   Telerik.Web.Mvc.UI.Html.GridActionCellBuilder.AppendCellContent(IHtmlNode td, Object dataItem) +83
   Telerik.Web.Mvc.UI.Html.GridDataCellBuilderBase.CreateCell(Object dataItem) +205
   Telerik.Web.Mvc.UI.<>c__DisplayClass3b.<InitializeEditors>b__38(GridColumnBase`1 column) +73
   Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each(IEnumerable`1 instance, Action`1 action) +136
   Telerik.Web.Mvc.UI.Grid`1.InitializeEditors() +830
   Telerik.Web.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer) +761
   Telerik.Web.Mvc.UI.ViewComponentBase.ToHtmlString() +106
   Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.ToHtmlString() +16
   System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, Object content) +17
   ASP._Page_Views_Activities_Index_cshtml.Execute() in c:\GreenroadTech\Applications\Main\GRT.MVC\GRT.MVC\Views\Activities\Index.cshtml:64
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +143
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +157
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +384
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +785284
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +785360
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +453
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +371


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225

issue 2:
i use GridEditMode.PopUpfor edit and i need to add a key for edit and i managed to add a key but when i try to edit a row i get a blank popup

P.S: i rather use popup
THNX
Alon
0
Atanas Korchev
Telerik team
answered on 24 May 2011, 04:19 PM
Hi alonav,

 Try this instead:

keys.Add(c => c.UnitId)


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
alonav
Top achievements
Rank 1
answered on 24 May 2011, 04:32 PM
Already tried it and got:
 

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1963: An expression tree may not contain a dynamic operation

Source Error:

Line 64: @(Html.Telerik().Grid<dynamic>()
Line 65:        .Name("Grid")
Line 66: .DataKeys(keys => { keys.Add(c => c.UnitId); })Line 67:        .ClientEvents(events => events.OnLoad("onGridLoad"))
Line 68:                .Columns(columns =>

Source File: c:\GreenroadTech\Applications\Main\GRT.MVC\GRT.MVC\Views\Activities\Index.cshtml    Line: 66






Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225


What about the other issue- empty popup edit window?
0
Atanas Korchev
Telerik team
answered on 25 May 2011, 05:57 AM
Hi alonav,

 You can check this code library project which shows how to use editing in grid bound to dynamic model. If this doesn't help I would ask you to send us your project so we can take a look and see what is wrong with the configuration.

Kind 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
Tags
Grid
Asked by
Ravindra
Top achievements
Rank 1
Answers by
Ravindra
Top achievements
Rank 1
alonav
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or