The documentation states the argument of LoadClientState is a string, this doesn't seem to be correct for RadGrid, it is a Dictionary<string,object>, and there is no overload that takes a string.
is there another IClientStateManager for collections?
is there another IClientStateManager for collections?
5 Answers, 1 is accepted
0

Brett
Top achievements
Rank 1
answered on 02 Dec 2014, 03:37 PM
Documentation Reference: http://www.telerik.com/help/aspnet-ajax/m_telerik_web_iclientstatemanager_loadclientstate.html
0
Accepted
Hello Brett,
The method differs for different controls.
The API reference is auto-generated from the assembly and it is correct.
Indeed the grid's method expects dictionary. In the base class it is called during the LoadPostData method:
You could use the same approach with the JavaScriptSerializer class to build dictionary from JSON string.
Regards,
Vasil
Telerik
The method differs for different controls.
The API reference is auto-generated from the assembly and it is correct.
Indeed the grid's method expects dictionary. In the base class it is called during the LoadPostData method:
protected
virtual
bool
LoadPostData(
string
postDataKey, NameValueCollection postCollection)
{
string
clientState = postCollection[ClientStateFieldID];
if
(!
string
.IsNullOrEmpty(clientState))
{
JavaScriptSerializer serializer =
new
JavaScriptSerializer();
var deserializedState = serializer.DeserializeObject(clientState)
as
Dictionary<
string
,
object
>;
if
(deserializedState !=
null
)
return
LoadClientState(deserializedState);
}
return
false
;
}
You could use the same approach with the JavaScriptSerializer class to build dictionary from JSON string.
Regards,
Vasil
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Brett
Top achievements
Rank 1
answered on 15 Dec 2014, 05:57 PM
hmm...the method in question is a method on an interface (IClientStateManager). It cannot differ in it's digital sigature. So are you saying that controls don't implement that interface? But may very well contain a method called LoadPostData?
0

Brett
Top achievements
Rank 1
answered on 15 Dec 2014, 06:26 PM
actually.. after reviewing RadGrid in Object Browser, I'm not entirely sure how I got the impression it was implementing IClientStateManager - or a variant - in the first place.
In your sample code, would ClientStateFieldID be a part of the postDataKey?
In your sample code, would ClientStateFieldID be a part of the postDataKey?
0
Hi,
IClientStateManager is a helper interface from the Telerik library intended for use in the client state persistence feature of the controls. However not all controls implement it. Some controls, such as RadGrid have their own custom implementation of the client state persistence feature.
A base class for most of the telerik controls that support databinding and can visualize data is the RadCompositeDataBoundControl implementing the following standard ASP.NET classes and interfaces:
It also adds a variety of internal properties one of which is the ClientStateFieldID property:
The property is used when the control renders a hidden input to hold all the client-side setting that will be serialized back to the server:
The LoadPostData method as defined in the IPostBackDataHandler interface takes as first argument the key identifier for the control - which in the example above will be simply the ID of the control: RadGrid1. The second parameter is a NameValueCollection of all the data posted back to the server, among which we also have the value of the hidden input holding the client state. That's why in the LoadPostData method we use the ClientStateFieldID property to get this value and deserialize it to grid settings.
I hope this helps.
Regards,
Marin
Telerik
IClientStateManager is a helper interface from the Telerik library intended for use in the client state persistence feature of the controls. However not all controls implement it. Some controls, such as RadGrid have their own custom implementation of the client state persistence feature.
A base class for most of the telerik controls that support databinding and can visualize data is the RadCompositeDataBoundControl implementing the following standard ASP.NET classes and interfaces:
public
abstract
partial
class
RadCompositeDataBoundControl : CompositeDataBoundControl, IScriptControl, IPostBackDataHandler
It also adds a variety of internal properties one of which is the ClientStateFieldID property:
[ClientControlProperty]
//helper attribute indicating the property value will be serialized on the client
[Browsable(
false
)]
public
string
ClientStateFieldID
{
get
{
return
ClientID +
"_ClientState"
;
}
}
The property is used when the control renders a hidden input to hold all the client-side setting that will be serialized back to the server:
<
input
id
=
"RadGrid1_ClientState"
name
=
"RadGrid1_ClientState"
type
=
"
hidden
"
autocomplete
=
"off"
>
The LoadPostData method as defined in the IPostBackDataHandler interface takes as first argument the key identifier for the control - which in the example above will be simply the ID of the control: RadGrid1. The second parameter is a NameValueCollection of all the data posted back to the server, among which we also have the value of the hidden input holding the client state. That's why in the LoadPostData method we use the ClientStateFieldID property to get this value and deserialize it to grid settings.
protected
virtual
bool
LoadPostData(
string
postDataKey, NameValueCollection postCollection)
{
string
clientState = postCollection[ClientStateFieldID];
I hope this helps.
Regards,
Marin
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.