ContentCssClass and load on demand via WebService

9 posts, 0 answers
  1. rwozniak
    rwozniak avatar
    47 posts
    Member since:
    Oct 2007

    Posted 18 Jan 2009 Link to this post

    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
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 19 Jan 2009 Link to this post

    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.
  3. rwozniak
    rwozniak avatar
    47 posts
    Member since:
    Oct 2007

    Posted 19 Jan 2009 Link to this post

    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

  4. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 20 Jan 2009 Link to this post

    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.
  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 20 Jan 2009 Link to this post

    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.
  6. GZ
    GZ avatar
    2 posts
    Member since:
    Oct 2006

    Posted 09 Apr 2009 Link to this post

    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

  7. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 10 Apr 2009 Link to this post

    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.
  8. GZ
    GZ avatar
    2 posts
    Member since:
    Oct 2006

    Posted 15 Apr 2009 Link to this post

    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
  9. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 17 Apr 2009 Link to this post

    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.
Back to Top