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

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

1 Answer 58 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 21 Jul 2011, 06:28 PM
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.

Sean

1 Answer, 1 is accepted

Sort by
0
Accepted
Pero
Telerik team
answered on 26 Jul 2011, 02:26 PM
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,
Pero
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!

Tags
Dock
Asked by
Sean
Top achievements
Rank 2
Answers by
Pero
Telerik team
Share this question
or