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

Change Edit mode of Detail grid

4 Answers 300 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 10 Feb 2015, 04:02 PM
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?

4 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 12 Feb 2015, 12:00 PM
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.

 
0
Michael
Top achievements
Rank 2
answered on 12 Feb 2015, 12:51 PM
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?
0
Michael
Top achievements
Rank 2
answered on 12 Feb 2015, 12:54 PM
@{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();
}

0
Alexander Popov
Telerik team
answered on 16 Feb 2015, 08:40 AM
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.

 
Tags
Grid
Asked by
Michael
Top achievements
Rank 2
Answers by
Alexander Popov
Telerik team
Michael
Top achievements
Rank 2
Share this question
or