Ticket Q357880
Visible to All Users

Is there any way to include the Treelist nodes in xml

created 13 years ago

Is there any method extension or smoething to include the Treelist nodes in XML SaveLayoutToStream.
I want this behaviour to preserve both data and layout, because i'm using an treelist as a "Favorites" and as a "Recent Items" implementation.
The goal is to save this to a sql databse. I already save the xml using the refered mrthos, but how can i include data in this method.

Show previous comments (1)
E E
Engº Silvio Cruz 13 years ago

    can u please send me a sample of saving nodes to xml and reading nodes to xml from the treelist.
    Thanks in Advance…

    DevExpress Support Team 13 years ago

      Hi Silvio,
      Please give me some additional time and I will provide you with an example.
      Thanks,
      John.

      E E
      Engº Silvio Cruz 13 years ago

        For instance I use this method to save treelist xml layout to database, how can i upgrade use the same method to save the nodes to database.
        public static bool GravaConfiguracaoGrelha(TreeList grelha, String nomeGrelha)
                {
                    try
                    {
                        MemoryStream stream = new MemoryStream();
                        grelha.SaveLayoutToStream(stream);
                        stream.Seek(0, SeekOrigin.Begin);
                        StreamReader reader = new StreamReader(stream);
                        Plat.PRIConnector.Executa("DELETE FROM TDU_ConfiguracaoGrelhas Where CDU_Grelha='" + nomeGrelha + "' and CDU_Utilizador='" + (Plat.PriLogin == null ? "" : Plat.PriLogin.Utilizador) + "'");
                        Plat.PRIConnector.Executa("INSERT INTO TDU_ConfiguracaoGrelhas(CDU_ID, CDU_Grelha, CDU_Config, CDU_Utilizador) VALUES ('" + Guid.NewGuid().ToString() + "', '" + nomeGrelha + "', '" + reader.ReadToEnd() + "', '" + (Plat.PriLogin == null ? "" : Plat.PriLogin.Utilizador) + "')");
                    }
                    catch (Exception)
                    {
                        return false;
                    }
                    return true;
                }

        Answers approved by DevExpress Support

        created 13 years ago (modified 9 years ago)

        Hi Silvio,
        Attached is a small sample project that illustrates how to add datasource data to layout data. I have used LINQ To Xml. I have saved data to a file, but you can also save it to a stream as the XElement object supports different save methods.
        Does this solution meet your requirements? If not, please feel free to reactivate ticket.
        Thanks,
        John.

          Show previous comments (2)
          DevExpress Support Team 13 years ago

            Hi Silvio,
            Thank you for your feedback. After data has been saved to a memory stream, the stream current position points to the end of the stream. Try to call the Seek(0, SeekOrigin.Begin) method for all memory streams before saving them to the database.

            C#
            ... mainStreamFavoritos.Seek(0, SeekOrigin.Begin); StreamReader readerFavoritos = new StreamReader(mainStreamFavoritos); ... mainStreamMaisRecentes.Seek(0, SeekOrigin.Begin); StreamReader readerMaisRecentes = new StreamReader(mainStreamMaisRecentes); ...

            Please feel free to reactivate this ticket if you need any further assistance on this issue.
            Thanks,
            John.

            E E
            Engº Silvio Cruz 13 years ago

              Thanks for your support.
              Issue Solved.

              E E
              Engº Silvio Cruz 13 years ago

                Thanks for your support.
                Issue Solved.

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.