This question is locked. New answers and comments are not allowed.
I'm trying to use the MVC Telerik Grid with a dynamic number of server-bound columns, and in-line Ajax editing. I've gotten the values to appear correctly in the dynamic columns, but when I click "edit" for the in-line editing, the edit value I get is an "empty" value for the field. For example if the grid shows 123.00 for a decimal, I get 0.00 when I edit it. If I then cancel the edit, the fields are blanked - not 123.00, or 0.00, but blank. I've attached sequential screenshots below
I'm using Telerik v. 2011.1.315.340 on Visual Studio 2010, MVC 3.
Here's my grid instantiation. It's a series of grids inside a PanelBar - sorry for the extra noise.
<% Html.Telerik().PanelBar() .Name("PhaseEstimatesPanelBar") .Items(items => { int phaseIndex = 0; foreach (var initiativePhase in Model.InitiativePhases) { // HACK - next unused funding source InitiativePhaseEstimate initiativePhaseEstimate = initiativePhase.GetInitiativePhaseEstimate(); FundingSource nextUnusedFundingSource = AllPossibleFundingSources.First(); if (initiativePhaseEstimate != null) { var usedFundingSources = initiativePhaseEstimate.GetFundingSources(); nextUnusedFundingSource = AllPossibleFundingSources.First(fs => !usedFundingSources.Contains(fs)); } // HTML of Button for adding a new Estimate var newEstimateButtonLink = SitkaRoute<InitiativeController>.BuildLinkFromExpression(c => c.CreateFundingSourceEstimateRow(initiativePhase.InitiativePhaseID, nextUnusedFundingSource.FundingSourceID), "Add Funding Source"); // This is grotesque, and deserves an explanation. // // Telerik Grid wants to call a default, parameterless constructor on the Model type of the grid, in this case FundingSourceEstimateRow. But my first crack at a parameterless constructor just // had a blank List of BudgetEstimates, which meant that the generated AJAX template did not have enough columns. So instead we set this static just-in-time before the parameterless constructor // is called in the grid so that it has the correct BudgetEstimate columns. // // The Default constructor is the *ONLY* member that needs these, and they should be otherwise ignored. // -- SLG FundingSourceEstimateRow.BudgetEstimateTemplatesForDefaultConstructor = FundingSourceEstimateRow.GetBlankBudgetEstimatesForInitiativePhaseEstimate(initiativePhaseEstimate, nextUnusedFundingSource); // Build grid control for the initiative phases var rowsForInitiativePhase = GetFundingSourceEstimateRows(initiativePhase); var gridContent = Html.Telerik().Grid<FundingSourceEstimateRow>(rowsForInitiativePhase) .Name(string.Format("InitiativePhaseEstimatimesGrid_PhaseID{0}", initiativePhase.ID)) .ToolBar(commands => commands.Insert()) .DataKeys(keys => keys.Add(x => x.ID)) .DataBinding(f => f.Ajax() .Select("EstimatesGridEditSelect", "Initiative") .Insert("EstimatesGridInsert", "Initiative") .Update("EstimatesGridSave", "Initiative") .Delete("EstimatesGridDelete", "Intiative")) .Columns(columns => { //columns.Bound(c => c.InitiativePhaseEstimateID).Hidden(); columns.Command(commands => { commands.Edit().ButtonType(GridButtonType.BareImage); commands.Delete().ButtonType(GridButtonType.BareImage); }).Width(200).Title("Actions"); //columns.Bound(c => c.ID).Title("Fund Estimate ID"); //columns.Bound(c => c.FundingSource.FundingSourceID).Title("Funding Source ID"); columns.Bound(c => c.FundingSource.HierarchicalDisplayName).Title("Funding Source").Width(200); var phaseEstimate = initiativePhase.GetInitiativePhaseEstimate(); if (phaseEstimate != null) { var fiscalYearQuarters = phaseEstimate.InitiativePhase.GetFiscalQuarters(); Action<int> addValueColumn = (i) => { columns.Bound(u => u.BudgetEstimates[i].EstimatedBudget).Title(fiscalYearQuarters[i].DisplayName).Width(90); }; int quarterColumnCount = fiscalYearQuarters.Count; for (int quarterIndex = 0; quarterIndex < quarterColumnCount; quarterIndex++) { addValueColumn(quarterIndex); } } }) .Editable(editing => editing.Mode(GridEditMode.InLine)) .Scrollable(scroll => scroll.Height(140)); // Only show the grid if there are existing BudgetEstimates for the Phase string gridContentHtml = string.Empty; if (initiativePhaseEstimate != null && initiativePhaseEstimate.BudgetEstimates.Any()) { gridContentHtml = gridContent.ToHtmlString(); } // Output Phase accordian item items.Add() .Text(initiativePhase.Name) .HtmlAttributes(new { @id = string.Format("estimate_phase_{0}", phaseIndex) }) .Content(() => { %> <%= newEstimateButtonLink %> <%= gridContentHtml %> <% if (initiativePhaseEstimate != null) %> <% { %> <div style="text-align:top;">Estimate Assumptions:</div> <textarea rows='10' cols='118'><%: initiativePhaseEstimate.Assumptions%></textarea> <% } %> <div><button name='Save'>Save</button></div> <% }); phaseIndex++; } }) .Render(); I've had the feeling now for a while (see the "grotesque hack" comment above) that I'm swimming upstream with this stuff - if a custom Ajax binding would be better, for example, please tell me.
Still, I feel like what I've done so far should work - the proper values *are* being displayed on the grid, and clicking edit and cancel are entirely client-side issues - none of my code is being called when this fails.
Thanks in advance for any help.