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

HashTable - ClientBinding

5 Answers 86 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Random
Top achievements
Rank 1
Random asked on 24 Oct 2012, 12:09 PM
Hi.

I would like to display values of a HashTable inside a ClientBinding, is this possible?

If not i would like to recommend it.
It should be possible to declare a container for the hashtable, and inside fields that can display the key and value of the hashtable, for all entries inside the hashtable the key/value pair will get duplicated and filled with there corresposing values till the end is reached.
How can i achieve this functionality when its not already possible?

5 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 29 Oct 2012, 07:43 AM
Hello Random,

When binding RadGrid on the client, the data must have a valid JSON syntax, in order to be properly parsed. So to achieve the desired functionality you need to serialize the data from the Hashtable and sent is to the client side as JSON objects. More information about RadGrid client side data binding you could find here:
http://www.telerik.com/help/aspnet-ajax/grid-client-side-binding-specifics.html
http://www.telerik.com/help/aspnet-ajax/grid-client-side-binding.html
Please give it try and let me know if you experience any problems. Looking forward for your reply.

Regards,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Random
Top achievements
Rank 1
answered on 07 Nov 2012, 01:33 PM
Thanks for the answer, the link goes to RadGrid and i am not sure if this also applies to RadListView.
Additional i dont think it fits my needs, for this i may need to clarify some parts.

I try to explain the problem with a simple made up problem.
Lets say i have a list of writers with associated books, my class for webservice could look like the following:
[DataContract]
public class Writer
{
[DataMember]
public string WriterID { get; set; }
[DataMember]
public string WriterName { get; set; }
[DataMember]
public List<Book> WrittenBooks { get; set; }
}
[DataContract]
public class Book
{
[DataMember]
public string BookID { get; set; }
[DataMember]
public string BookName { get; set; }
[DataMember]
public decimal BookPrice { get; set; }
}

Now i'd like to display some writers (depending on filterparameters) with all their writtenbooks.
<telerik:RadListView ID="writerList" runat="server">
    <LayoutTemplate>
        <div id="writerItemContainer">
        </div>
    </LayoutTemplate>
    <ClientSettings>
        <DataBinding ItemPlaceHolderID="writerItemContainer">
            <ItemTemplate>
                <span>#= WriterID #</span>
                <span>#= WriterName #</span>
        <ul #ListOfBooks# >
            <li>#= BookID ##= BookName ##= BookPrice #</li>
        </ul>
            </ItemTemplate>
            <DataService Location="WebService.svc" DataPath="GetWriterList" />
        </DataBinding>
    </ClientSettings>
</telerik:RadListView>

The "basic information" is easy to display but how would i display a list of the property "WrittenBooks", is there a way to tell it should step threw a List/Collection/HashTable property and display each value of the enumeration.
My desired functionality should duplicate the <li> element for every entry in the enumeration and be filled with the corresponding values.

In RadGrid this would be like having a DetailsTableView, is there something similar in RadListView with clientbinding?


Edit:
Additional question, is there a possibility to prevent loading data from the webservice on page load?!?
I only want the webservice be fired when i manually call .rebind() in javascript and not on postbacks/page load.
0
Radoslav
Telerik team
answered on 12 Nov 2012, 08:20 AM
Hi Random,

Unfortunately the RadListView does not support hierarchy binding.  The desired functionality could be achieved with some custom code. You could try calling the web service manually, get all the related data, then based on it you could create and append “li” elements to the “ul” by javascript.  However please note that this is not supported scenario.
Regarding your second question:
To avoid automatic data binding of the RadListView on pageLoad you need to use programmatic data binding where you could manually get data form the web service and show it on the RadListView. Online example demonstrating this approach could be found here:
http://demos.telerik.com/aspnet-ajax/listview/examples/client/programmaticdatabinding/defaultcs.aspx

I hope this helps.

Greetings,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Random
Top achievements
Rank 1
answered on 12 Nov 2012, 10:22 AM

To bad that this functionality isnt supported yet.
Is this it already in the pipeline?
I couldnt find an issue in the PIT system, is it possible to creat one so i and others can vote for this.
I definetly believe not only I am interessted in such a functionality.

About the pageload binding i found the following help article:
http://www.telerik.com/help/aspnet-ajax/listview-clientside-binding-specifics.html

On this site there you can find the following part:

Client-side LayoutTemplate as a container of client-bound items

In this scenario the client-side RadListView.ClientSettings.DataBinding.LayoutTemplate is defined. RadListView.ClientSettings.DataBinding.ItemPlaceHolderID points to the ID of an HTML element inside the client-side LayoutTemplate. The server-side LayoutTemplate is omitted. This approach is recommended for scenarios where no server-side databinding is required and RadListView does not have to render content from the server on initial page load.

According to this the elements should not render, but this doesnt seem the case everything gets displayed on page load, service gets called and so on. Is this information out dated or is something going wrong?
(Notice that the code from above doesnt reflect this, and has been changed on my side to fit the help article but no difference can be seen)

0
Radoslav
Telerik team
answered on 15 Nov 2012, 08:26 AM
Hello Random,

Unfortunately we do not have plans for implementing client side hierarchy binding of the RadListView.  Additionally regarding the question concerning the LayoutTemplate:
Indeed the server-side LayoutTemplate will not be loaded, however the client-side LayoutTemplate will be. So in your case the div with id “writerItemContainer“ will be rendered, the service will be called and all elements into the ClientSettings.DataBinding.ItemTemplate will be appended to it.

I hope this helps.

Regards,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ListView
Asked by
Random
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Random
Top achievements
Rank 1
Share this question
or