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

How to force RowSourceNeeded

2 Answers 23 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris Kirkman
Top achievements
Rank 1
Chris Kirkman asked on 01 Feb 2018, 07:44 PM

I have a GridView with many rows (let's call it Grid A).  Within each row there is another GridView (Grid B).  This is created when the RowSourceNeeded event is raised. 

When the user changes a value in one of the columns in my GridView (Grid A), I need this to result in removing the GridView (Grid B) that was added during RowSourceNeeded and have the event be raised again.

2 Answers, 1 is accepted

Sort by
0
Chris Kirkman
Top achievements
Rank 1
answered on 01 Feb 2018, 08:32 PM

Looks like this will work.  In the CellEndEdit event I can access my model, reload the values that I'll need after the change and then assign those values to the existing rows in the hierarchical child grid.

 

Interesting tidbit though.  If I don't set the IsExpanded to false and then true the changes are not reflected in the UI.  Almost seems like this is a refresh issue of some sort.

 

private async void BatchComparisonGridCellEndEdit(object sender, GridViewCellEventArgs e)
{
    // get the selected id and reload the gamma for this reference scan
    ComparisonScanViewModel model = BatchComparisonGrid.CurrentRow.DataBoundItem as ComparisonScanViewModel;
 
    // tell user finding gamma
    UpdateWaitingBar(ElementVisibility.Visible, "Calculating Passing Percentage...");
 
    // calculate gamma
    if (null != model)
        await model.FindGamma(Convert.ToInt32(e.Value));
 
    if (null != BatchComparisonGrid.CurrentRow.ViewTemplate.ChildRows &&
        0 != BatchComparisonGrid.CurrentRow.ViewTemplate.ChildRows.Count)
    {
        // refresh the row details table (which shows the analysis parameters)
        foreach (GridViewRowInfo row in BatchComparisonGrid.CurrentRow.ViewTemplate.ChildRows[0].ChildRows)
        {
            // update each row
            row.Cells[PARAMETER_ROW_VALUE].Value =
                model.Parameters.FirstOrDefault(p =>
                p.Title == (string)row.Cells[PARAMETER_ROW_DESCRIPTION].Value).Value;
        }
 
        BatchComparisonGrid.CurrentRow.IsExpanded = false;
        BatchComparisonGrid.CurrentRow.IsExpanded = true;
    }
 
    // refresh in the UI
    LoadChart(model);
 
    // tell user done
    UpdateWaitingBar(ElementVisibility.Collapsed);
}
0
Accepted
Dimitar
Telerik team
answered on 02 Feb 2018, 01:10 PM
Hello Chris,

Yes, collapsing/expanding will trigger the event. Here is another approach:
var row = ((GridViewHierarchyRowInfo)radGridView1.CurrentRow);
row.Views[0].Refresh();

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Chris Kirkman
Top achievements
Rank 1
Answers by
Chris Kirkman
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or