Change Edit mode of Detail grid

5 posts, 0 answers
  1. Michael
    Michael avatar
    3 posts
    Member since:
    Sep 2014

    Posted 10 Feb 2015 Link to this post

    This may be way out there, but figure it can't hurt to ask.

    We are using MVC Razor Grid, and have a Master/Detail grid working. However, is there any way to dynamically (ondatabound, etc) set the Detail grid for a particular Master Row as Editable(false)? The Master grid contains a year column, and we want the Details grids to only be editable if the year is the current year or later. Can the Grid's Editable attribute be set by jquery?
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 12 Feb 2015 Link to this post

    Hello Michael,

    Yes, the editable option can be modified using the setOptions method, as shown in this example.

    Regards,
    Alexander Popov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Michael
    Michael avatar
    3 posts
    Member since:
    Sep 2014

    Posted 12 Feb 2015 in reply to Alexander Popov Link to this post

    I understand that one, and did find it inthe Kendo documentation. Unfortunately, our app is too big to allow for us to migrate to Kendo (not to mention the red tape we have to go through, here!), at this time... The app was built on ASP.NET MVC, build 2012.1.214. Is there any option for similar functionality with the MVC Raxor grid?
  4. Michael
    Michael avatar
    3 posts
    Member since:
    Sep 2014

    Posted 12 Feb 2015 in reply to Michael Link to this post

    @{Html.Telerik().Grid<GDOT.TPRO.Core.OBLIG_CAT_BEG_BALANCE>()
        .Name("Obligations")
        .DataKeys(keys => keys
            .Add(c => c.OBLIGCAT_BEGBAL_ID)
            .RouteKey("OBLIGCAT_BEGBAL_ID"))
        .DataBinding(dataBinding => dataBinding.Ajax()
                .Select("AjaxObligationHierarchy", "SysAdmin")
                .Insert("AjaxAddObligation", "SysAdmin" )
                .Update("AjaxSaveObligation", "SysAdmin"))
        .Columns(columns =>
        {
            columns.Bound(c => c.FISCAL_YEAR).Title("Fiscal Year").Width(60);
            columns.Bound(c => c.BEG_BALANCE_AMT).Title("Beginning Balance").Format("{0:c}").ReadOnly().Width(160).HtmlAttributes(new { style = "text-align:right;" }); 
            columns.Bound(c => c.OBLIG_CAT_CD).Title("Obligation Category").Width(90);
            columns.Bound(c => c.EFFDT).Title("Effective Date").Format("{0:MM/dd/yyyy}").Width(120);
            columns.Bound(c => c.COMMENTS).Title("Comments");
            columns.Bound(c => c.LASTUPDUSER).Title("Last Update By").ReadOnly().Width(125);
            columns.Command(commands => commands.Edit()).Width(80);
        })
        .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Text).HtmlAttributes(new { style = "color:black", text="sdf"}))
        .ClientEvents(events => events
            .OnError("onError")
            .OnEdit("onEditObligation")
            .OnSave("onSaveObligation")
            .OnDetailViewExpand("onDetailViewExpand")
           )
        .Editable(editing => editing.Mode(GridEditMode.InLine))
        .Pageable(pagerAction => pagerAction.PageSize(10))
        .Sortable()
        .Filterable()
        .DetailView(details => details
            .ClientTemplate(Html.Telerik().Grid<GDOT.TPRO.Core.STIPCLASS_BEG_BALANCE>()
                .Name("STIP_<#= OBLIGCAT_BEGBAL_ID #>")
                .Columns(columns =>
                {

                    columns.Bound(c => c.STIP_CLASS).Title("STIP Class").Width(120);
                    columns.Bound(c => c.BEG_BALANCE_AMT).Title("Beg Balance Amount").Format("{0:C}").Width(140).HtmlAttributes(new { style = "text-align:right;" });
                    columns.Bound(c => c.EFFDT).Title("Effective Date").Format("{0:MM/dd/yyyy}").Width(115); 
                    columns.Bound(c => c.COMMENTS).Title("Comments");
                    columns.Bound(c => c.LASTUPDUSER).Title("Last Update By").ReadOnly().Width(90);
                    columns.Command(commands => commands.Edit()).Width(80);
                    
                })
                .ToolBar(commands => commands.Insert().HtmlAttributes(new { style = "color:black" ,@class=".kgk"}))   
                .DataBinding(dataBinding => dataBinding.Ajax()
                    .Select("AjaxObligationSTIPHierarchy", "SysAdmin", new { obligationId = "<#= OBLIGCAT_BEGBAL_ID #>" })
                    .Insert("AjaxAddSTIP", "SysAdmin", new { obligationId = "<#= OBLIGCAT_BEGBAL_ID #>" })
                    .Update("AjaxSaveSTIP", "SysAdmin", new { obligationId = "<#= OBLIGCAT_BEGBAL_ID #>" }))
                .DataKeys(keys => 
                    {
                        keys.Add(o => o.STIPCLASS_BEGBAL_ID).RouteKey("STIPId");
                        keys.Add(o => o.OBLIGCAT_BEGBAL_ID).RouteKey("ObligId");
                    }
                    )
                .ClientEvents(events => events
                    .OnError("onError")
                    .OnEdit("onEditSTIPClass")
                    .OnSave("onSaveSTIPClass")
                    .OnDataBound("Grid_onDataBound")
                    .OnComplete("Grid_onComplete")
                    )
                .Scrollable()
                .Editable(editing => editing.Mode(GridEditMode.InLine))
                .Sortable()
                .Filterable()
                .ToHtmlString()
        ))
        .Render();
    }

  5. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 16 Feb 2015 Link to this post

    I apologize for the misunderstanding Michael.

    Changing the editable options at run-time is unsupported in the Telerik Extensions for ASP.NET MVC. You can try achieving similar behavior using the Grid's edit event handler instead. Once the even it triggered you can check the dates and if the conditions are met - call the cancelChanges method

    I also would like to remind you that as of June 2013 the product is no longer supported and that migrating to Kendo UI is highly recommended.

    Regards,
    Alexander Popov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top