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

ContentCssClass and load on demand via WebService

8 Answers 152 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
rwozniak
Top achievements
Rank 1
rwozniak asked on 18 Jan 2009, 05:31 PM
I updated my tree view to load its child nodes via web service, but am experiencing problems with ContentCssClass. I am setting this property in the RadTreeNodeData objects that are returned from the web service, but the css class that I specified doesn't appear in the divs that are returned (they only have a class of rtTop).

When support for ContentCssClass was added recently, was support for it in a web service scenario perhaps overlooked?

Thanks,
Ross

8 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 19 Jan 2009, 09:00 AM
Hi rwozniak,

Indeed the current load on demand logic does not support the ContentCssClass property. I have logged it for implementation for the next release. For now you can use this as a workaround:

        <script type="text/javascript">
        function nodeDataBound(sender, args)
        {
            var node = args.get_node();
            var dataItem = args.get_dataItem();
           
            Sys.UI.DomElement.addCssClass(node.get_contentElement(), dataItem["ContentCssClass"]);
        }
        </script>
        <telerik:RadTreeView runat="Server" ID="RadTreeView1" OnClientNodeDataBound="nodeDataBound" >
        <WebServiceSettings Method="GetNodes" Path="webService.asmx" />
            <Nodes>
                <telerik:RadTreeNode runat="server" ExpandMode="WebService" >
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeView>

All the best,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
rwozniak
Top achievements
Rank 1
answered on 19 Jan 2009, 05:34 PM
Thanks Albert,

This did get me closer, but there is still a flaw. It adds it to all nodes but the first and the last. Basically, all nodes w/ a class of 'rtMid' are ok, but those with 'rtTop' and 'rtBot' are still missing the css class.

Ross

0
Atanas Korchev
Telerik team
answered on 20 Jan 2009, 08:06 AM
Hi rwozniak,

Indeed, you are right. The first and last node have their CSS class cleared for some reason. I have notified our developers and they will try to fix the issue altogether so you don't need to write javascript code. I will let you know once this problem is solved.

All the best,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Atanas Korchev
Telerik team
answered on 20 Jan 2009, 11:24 AM
Hello rwozniak,

The problem should be solved now. The hotfix will be included in tomorrow's internal build.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
GZ
Top achievements
Rank 1
answered on 09 Apr 2009, 01:41 PM
Hi

I'm using the same setup (webService) and experiencing a similar problem with the Enable/Disable functionality.

Tried without the DataBound callback but then the only thing I could se was that the image wasn't loaded.
After adding custom code to DataBound (below) the "mid" nodes gets disabled (not the first and last ones) but the images is loaded ok.

 

function treeNode_DataBound(sender, eventArgs)   
{  
var node = eventArgs.get_node();  
var dataItem = eventArgs.get_dataItem();  
node.set_enabled(dataItem.Enabled);  

I'm using ver 2009.01.0402.20

Thanks
Peter

0
Atanas Korchev
Telerik team
answered on 10 Apr 2009, 12:29 PM
Hi GZ,

Which image is not loaded? Also the enabled property should be automatically populated when using WebService load on demand. Please elaborate. Ideally you could paste here the body of your web method.

Regards,
Albert
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
GZ
Top achievements
Rank 1
answered on 15 Apr 2009, 02:00 PM
Hi Albert

I've created a small test project but realized i couldn't upload the zip. Anyway here is the test WS


[WebService(Namespace = 
"http://tempuri.org/")]  
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]  
[System.Web.Script.Services.ScriptService]  
public class TreeService : System.Web.Services.WebService  
{  
 
    public class NodeData  
    {  
        public bool Enabled;  
        public string Text;  
        public Telerik.Web.UI.TreeNodeExpandMode ExpandMode;  
        public string ImageUrl;  
    }  
 
    public TreeService()  
    {  
    }  
 
    internal static NodeData[] GetNodes(string prefix)  
    {  
        int size = 9;  
        NodeData[] ret = new NodeData[size];  
        for (int i = 0; i < size; i++)  
        {  
            NodeData nd = new NodeData();  
            nd.Enabled = (i % 3 == 0);  
            nd.Text = prefix + " " + i.ToString() + (string)((nd.Enabled) ? " Enabled" : " Disabled");  
            nd.ExpandMode = (i % 2 == 0) ? Telerik.Web.UI.TreeNodeExpandMode.WebService : Telerik.Web.UI.TreeNodeExpandMode.ClientSide;  
            nd.ImageUrl = "file_txt_16.gif";  
            ret[i] = nd;  
        }  
 
        return ret;  
    }  
 
    [WebMethod]  
    public NodeData[] GetNodes(NodeData node, object context)  
    {  
        return TreeService.GetNodes(node.Text);  
    }  
 
Javascript
<script type="text/javascript">  
    function OnNodeDataBound(sender, eventArgs)   
    {  
        var node = eventArgs.get_node();  
        var dataItem = eventArgs.get_dataItem();  
        node.set_enabled(dataItem.Enabled);  
    }  
</script> 
and finally
<telerik:RadTreeView ID="RadTreeView4" runat="server" OnClientNodeDataBound="OnNodeDataBound">  
                <WebServiceSettings Path="~/TreeService.asmx" Method="GetNodes" UseHttpGet="false" /> 
                <Nodes> 
                    <telerik:RadTreeNode runat="server" Enabled="true" Text="Root" ExpandMode="WebService">  
                    </telerik:RadTreeNode> 
                </Nodes> 
            </telerik:RadTreeView> 

Please also test without the OnClientNodeDataBound script

I've also tried to add the same nodes (as RadTreeNode's) on server event "Node_Expand" and it works as expected.

thanks in advance
Peter
0
Atanas Korchev
Telerik team
answered on 17 Apr 2009, 07:48 AM
Hello GZ,

Thank you for providing this sample code. It clearly demonstrates that the last disabled node looks enabled. I have notified our development team and they will address this bug. The hotfix will be incorporated in Monday's internal build. I have updated your Telerik points.

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
rwozniak
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
rwozniak
Top achievements
Rank 1
GZ
Top achievements
Rank 1
Share this question
or