Accessing custom properties of a RadDock client-side NOT using Attributes?

2 posts, 1 answers
  1. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 21 Jul 2011 Link to this post

    Hey Telerik,

    This isn't a huge thing, but I'm looking for a solution that is better than storing data inside of the AttributeCollection field. 

    Basically, I do this:

    //TODO: Make this obsolete. Somehow. Probably through thinking!
    public void SetAttributes()
        Logger.InfoFormat("Setting Attributes for {0}: ", ID);
        Attributes["RefreshEnabled"] = RefreshEnabled.ToString();
        Logger.InfoFormat("RefreshEnabled: {0}: ", RefreshEnabled);
        Attributes["RefreshInterval"] = RefreshInterval.ToString();
        Logger.InfoFormat("RefreshInterval: {0}: ", RefreshInterval);
        Attributes["ChartType"] = ChartType.ToString();
        Logger.InfoFormat("ChartType: {0}: ", ChartType);
        Attributes["ReportType"] = ReportType.ToString();
        Logger.InfoFormat("ReportType: {0}: ", ReportType);
        Attributes["TimeRestrictionEnabled"] = TimeRestrictionEnabled.ToString();
        Logger.InfoFormat("TimeRestrictionEnabled: {0}: ", TimeRestrictionEnabled);
        Attributes["TimeStart"] = TimeStart.ToString();
        Logger.InfoFormat("TimeStart: {0}: ", TimeStart);
        Attributes["TimeEnd"] = TimeEnd.ToString();
        Logger.InfoFormat("TimeEnd: {0}: ", TimeEnd);
        Attributes["DataPointsEnabled"] = DataPointsEnabled.ToString();
        Logger.InfoFormat("DataPointsEnabled: {0}: ", DataPointsEnabled);
        Attributes["ReportID"] = Chart.ReportID.ToString();
        Logger.InfoFormat("ReportID: {0}: ", Chart.ReportID.ToString());

    and then, for instance, when the user clicks a custom command on the RadDock which opens a RadWindow, I would like to populate the RadWindow with data about the RadDock.

    As such, I store the fields in Attributes so that they are accessible client-side. 

    //Opens a historical report settings window -- passing the known settings to it
    //so that the window will show the proper data to the user.
    function OnHistoricalLocalSettingsShow(sender, eventArgs) {
        var historicalAttributes = {};
        var radDockElement = radDock.get_element();
        historicalAttributes["RefreshEnabled"] = radDockElement.getAttribute("RefreshEnabled");
        historicalAttributes["RefreshInterval"] = radDockElement.getAttribute("RefreshInterval");
        historicalAttributes["ChartType"] = radDockElement.getAttribute("ChartType");
        historicalAttributes["TimeRestrictionEnabled"] = radDockElement.getAttribute("TimeRestrictionEnabled");
        historicalAttributes["TimeStart"] = radDockElement.getAttribute("TimeStart");
        historicalAttributes["TimeEnd"] = radDockElement.getAttribute("TimeEnd");
        historicalAttributes["DataPointsEnabled"] = radDockElement.getAttribute("DataPointsEnabled");
        sender.argument = historicalAttributes;

    I find this slightly harder to maintain than I would like, though. There is no guarantee that the data being stored in the dock is current and up-to-date. I would like to be pulling the data from the RadDock's properties directly from client-side, or possibly posting an AJAX call to go fetch the data from the server on-demand.

    I looked into this a bit and I read about Page Methods some. I'm not sure if this would be a better solution, though. So, I'm keeping my ears open for any other suggestions.

    Just a thought :) Thanks.

  2. Answer
    Pero avatar
    1156 posts

    Posted 26 Jul 2011 Link to this post

    Hi Sean,

    The RadDock's client-side properties pull data from the respective server-side properties, when the dock's client object is recreated on the client. This happens only on full postbacks, or ajax calls when the dock is actually affected by the request. In these cases the RadDock's HTML also gets regenerated, which means the attribute collection has the values that client-side properties would have if such were exposed. This being said, even if we have created client-side properties for the values you are passing through attributes we would have the same (data) concurrency.

    I can't think of a better way at the moment for passing data from server to the client, except by using the attribute collection.

    All the best,
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top