Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • MK 429 posts 906 karma points
    Aug 14, 2013 @ 11:25
    MK
    0

    Data grid wont sort.

    Hi there,

    A few days ago I upgraded my uComponents from 5.4.1 to 5.5.0 and everything seems fine except that the datagrid is not sorting the rows. 

    Any ideas?

    Many thanks

    mkariti

  • MK 429 posts 906 karma points
    Aug 14, 2013 @ 11:49
    MK
    0

    Just for reference - sorting it via Xdoc for now.

     

        XDocument xDoc = XDocument.Parse(CurrentPage.history.ToString());

        var doc = xDoc.Element("items").Elements("item").OrderByDescending(n => n.Value);

        XDocument sortedGrid = new XDocument(new XElement("items", doc));

    loop:

       @foreach (XElement xe in sortedGrid.Descendants("item"))

                       {

    @xe.Element("year").Value

    }

     

    Thanks

  • maanehunden 61 posts 105 karma points
    Oct 30, 2013 @ 13:53
    maanehunden
    0

    Well.. you should sort on "sortOrder" attribute of your datagrid item. 

    take a look at the datagrids XML, stored in your umbraco.config, could besomething like that,,..

      <datagrid>
        <items>
          <item id="1" sortOrder="3">
            <news nodeName="Image" nodeType="1034">1111</image>
          </item>
          <item id="2" sortOrder="1">
            <news nodeName="Image" nodeType="1034">1121</image>
          </item>
          <item id="3" sortOrder="2">
            <news nodeName="Image" nodeType="1034">1311</image>
          </item>
        </datagrid>

     

    happy coding (c:

  • MK 429 posts 906 karma points
    Oct 30, 2013 @ 14:12
    MK
    0

    XDocument xDoc = XDocument.Parse(datagrid);

                var doc = xDoc.Element("items").Elements("item").OrderBy(n => int.Parse(n.Attribute("sortOrder").Value));

                XDocument sortedGrid = new XDocument(new XElement("items", doc));

                return sortedGrid;

Please Sign in or register to post replies

Write your reply to:

Draft