Copied to clipboard

Flag this post as spam?

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


  • Anton 135 posts 186 karma points
    Feb 21, 2012 @ 01:57
    Anton
    0

    How get all nodes from database?

    I see table cmsPropertyData, How I can get all information from this table?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 21, 2012 @ 09:36
    Ismail Mayat
    0

    Anton,

    What exactly are you trying to do? You want all the nodes or you want all the properties for a given node?

    Regards

    Ismail

  • Anton 135 posts 186 karma points
    Feb 21, 2012 @ 09:43
    Anton
    0

    Ismail,

    I want all the nodes with all the properties for a each node

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 21, 2012 @ 10:00
    Ismail Mayat
    2

    Anton,

    Why not just use the api?  Node n = new Node(1234)  where you replace 1234 with node id of your home page.  Then do foreach(n.Children) then in the loop n.GetProperties and loop through those.

    In the grand scheme of things what exactly are trying to build? May help in determining if this is the best way forward.

    Regards

    Ismail

  • Anton 135 posts 186 karma points
    Feb 21, 2012 @ 10:10
    Anton
    0

    I want build table with all nodes. I have node car, this node has properies(model, year, fuel, volume, etc)

    this is columns of this table

    ID MODEL YEAR FUEL VOLUME

     

     

    What the best way to do it? and then I want to have sorting for each column. 

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Feb 21, 2012 @ 10:19
    Ismail Mayat
    0

    Anton,

    What version of umbraco are you using? If later than 4.5.2 then use examine.  Do a search on here on how to setup examine , there are videos on umbracotv as well. So you would create an examine index for nodetypealias car with all the properties you require.  Searching / sorting etc will be lightening fast.

    Regards

    Ismail

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 21, 2012 @ 14:00
    Lee Kelleher
    0

    Hi Anton,  (noticed your other forum posts on the same topic)

    Once you have a table with all the data in a "pivoted" view (e.g. properties names/aliases for columns) ... what will you do with it? (e.g. CSV export)

    I guess the point that Ismail and I are trying to get at is, to do this purely in T-SQL will be a headache.  Using the API and/or Examine/Lucene to query the data and present it in an appropriate format would be much easier.

    Cheers, Lee.

  • Anton 135 posts 186 karma points
    Feb 21, 2012 @ 14:19
    Anton
    0

    I want to do table by jqGrid, its working with database, I add  SelectCommand to jqGrid and it sorting table in client side by javascript. Now I dont know, what I must do(  For example http://www.trirand.net/demoaspnet.aspx.  How I can realise it by Umbraco? Give me advise please.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 21, 2012 @ 14:56
    Lee Kelleher
    2

    Hi Anton,

    On the jqGrid documentation pages, there is information about populating from an XML and DataTable sources.  It is looking like you would need to write some custom code to populate the data-source.

    A quick snippet would be like this...

    // create the table schema
    var table = new System.Data.DataTable();
    table.Columns.Add("Id", typeof(int));
    table.Columns.Add("Model", typeof(string));
    table.Columns.Add("Year", typeof(string));
    table.Columns.Add("Fuel", typeof(string));
    table.Columns.Add("Volume", typeof(string));
    
    // query the nodes that you want to get (using uComponents/uQuery)
    var nodes = uComponents.Core.uQuery.GetNodesByXPath("descendant::DocTypeAlias");
    foreach (var node in nodes)
    {
        // create new row
        var newRow = table.NewRow();
    
        // populate the row
        newRow[0] = node.Id;
        newRow[1] = node.GetProperty("model").Value;
        newRow[2] = node.GetProperty("year").Value;
        newRow[3] = node.GetProperty("fuel").Value;
        newRow[4] = node.GetProperty("volume").Value;
    
        // add the row to the table
        table.Rows.Add(newRow);
    }
    
    // bind to the jqGrid
    JQGrid1.DataSource = table;
    JQGrid1.DataBind();

    Note that I am using uComponents/uQuery to get the nodes of a specific doc-type alias.  You could do this using the Umbraco API, but it involves more code.

    Also this code is untested - wrote it completely off the top of my head.

    Enjoy!

    Cheers, Lee.

Please Sign in or register to post replies

Write your reply to:

Draft