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

Disable Action?

2 Answers 232 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Travis
Top achievements
Rank 1
Travis asked on 18 Apr 2011, 10:53 PM
Is there a way to disable the action for a textbox on a databound event?  I'm using an action on a table item to navigation to a drilldown report.  There is no child report, it just opens the same report and navigates to the next node in my hierarchy tree so to speak.  I'm simply passing a value to the same report to indicate who the drilldown parent is.  Everything works fine until I get to the point where there are no more children and I don't want the action to do anything at this point otherwise it will take me to a report with no results.

I've been able to work around my problem by creating two versions of the textbox that contains my action.  One with the action and one without the action.  The one textox is superimposed on the other.  I then simply hide or show the appropriate textbox on a databound event.  Unfortunately, I've run into a problem with this approach and the table object.  A table column can contain only one textbox, so I can't have two different versions of the textbox in a single column.  I can't use two columns, hide one and show the other since some rows may have child reports and some may not. 

2 Answers, 1 is accepted

Sort by
0
Travis
Top achievements
Rank 1
answered on 19 Apr 2011, 12:36 AM
I found another work around which I think will work for me.  I used an expression in my "navigate to report"  action and set it to "Null" if the conditions were not met.  This effectively "disabled" the action.
0
Nick Jacka
Top achievements
Rank 1
answered on 03 Aug 2012, 02:04 AM
Hi Travis,

This is well after the fact but it may be of use to others trying to set conditional actions.

I have managed to set the action of a TextBox in one of my Telerik Reports with the following code at runtime:
private void YourTextBox_ItemDataBinding(object sender, System.EventArgs e)
{
    var trpTextBox = sender as Telerik.Reporting.Processing.TextBox;
    if (trpTextBox != null)
    {
        var detailSection = trpTextBox.ParentElement as Telerik.Reporting.Processing.DetailSection;
        if (detailSection != null)
        {
            var Your_bound_data_object = detailSection.DataObject.RawData as Your_bound_data_object_type;
            if (Your_bound_data_object != null)
            {
                var reportItemBase = trpTextBox as Telerik.Reporting.Processing.ReportItemBase;
                if (reportItemBase != null)
                {
                    var trTextBox = reportItemBase.ItemDefinition as Telerik.Reporting.TextBox;
                    if (trTextBox != null)
                    {
                        if (Your_condition_test)
                        {
                            var navigateToReportAction = new Telerik.Reporting.NavigateToReportAction();
                            navigateToReportAction.ReportSource = new Telerik.Reporting.InstanceReportSource() { ReportDocument = new Your_report() };
                            navigateToReportAction.ReportSource.Parameters.Add(new Telerik.Reporting.Parameter("Your_parameter_name", Your_bound_data_object_property_or_some_other_value));
 
                            trTextBox.Action = navigateToReportAction;
                        }
                        else
                        {
                            trTextBox.Action = null;
                        }
                    }
                }
            }
        }
    }
}

This could also be used to attach different actions or drill through to different reports to the same TextBox in different rows based on your conditional logic.

Regards,
Nick
Tags
General Discussions
Asked by
Travis
Top achievements
Rank 1
Answers by
Travis
Top achievements
Rank 1
Nick Jacka
Top achievements
Rank 1
Share this question
or