Copied to clipboard

Flag this post as spam?

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


  • Dafydd Owen 33 posts 173 karma points
    May 11, 2014 @ 11:16
    Dafydd Owen
    0

    Problems retrieving list data using DataTypeGrid using nodeType and InnerText

    Hello, I'm hoping someone might have experienced the same problems I am encoutering and might be able to help with a solution. 

    The issue seems to arrise when I use the .nodeType and .InnerText methods from the razor examples provided here http://ucomponents.org/data-types/datatype-grid/razor-samples/ to retrieve the value of the selected list item from a dropdown datatype.

    At first I used the examples with my own custom datatypes but after failing with this, I tried setting up the datatype Grid exactly how the documentation displays them.  

    In both scenarios, I receive the errors

    'uComponents.DataTypes.DataTypeGrid.Model.GridCell' does not contain a definition for 'InnerText' 
    'uComponents.DataTypes.DataTypeGrid.Model.GridCell' does not contain a definition for 'nodeType'

    While setting up the .cshml macro, I recieved the warning;

    error CS0104: 'uQuery' is an ambiguous reference between 'umbraco.uQuery' and 'uComponents.Core.uQuery' 

    I tried both libraries but the errors are still present. 

    Using Umbraco Version: 4.11.10 

    Thanks 

  • Jan Skovgaard 10752 posts 21091 karma points admin mvp c-trib
    May 11, 2014 @ 11:43
    Jan Skovgaard
    0

    Hi Dafydd

    What version of uComponents are you using? And do you mind sharing the full code sample?

    /Jan

  • Dafydd Owen 33 posts 173 karma points
    May 11, 2014 @ 15:16
    Dafydd Owen
    0

    Hi Jan,

    Thanks for responding! 
    I am using version 5.5.4 of uComponents.

    Below is the code that I am testing, it's the example from the uComponents docs and it matches what I am trying to achieve. Since I recieve the same errors for both my custom razor and the demo code, it's propbably easier to work with this version.

    The datatypes I am using match the datatypes found in this explanation http://ucomponents.org/data-types/datatype-grid/razor-samples/

    I can also provide my original .cshtml code if it helps.

     

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using uComponents.Core
    @using umbraco.cms.businesslogic.datatype
    
    
    <ul>
        @foreach(var item in Model.DataTypeGrid) {
            @* Inside here, everything is case-sensitive *@
            <li>ID: @item.id
                <table>
                    <tr>
                        <th>XML</th>
                    </tr>
                    <tr>
                        <th>Image</th>
                        <td><img src="@Library.MediaById(int.Parse(item.image.InnerText)).UmbracoFile" width="100" height="100"/></td>
                    </tr>
                    <tr>
                        <th>Dropdown List</th>
                        <td>
                            <ul>
                            @* Display prevalue name instead of id *@
                            @{ IList<PreValue> preValues1 = umbraco.uQuery.GetPreValues(int.Parse(item.list.nodeType)); }
                            @foreach(var i in item.list.InnerText.Split(',')) {
                                <li>@preValues1.Single(x => x.Id.ToString() == i).Value (#@i)</li>
                            }
                            </ul>
                        </td>
                    </tr>
                    <tr>
                        <th>Dropdown Multi</th>
                        <td>
                            <ul>
                            @* Display prevalue name instead of id *@
                            @{ IList<PreValue> preValues2 = umbraco.uQuery.GetPreValues(int.Parse(item.multiList.nodeType)); }
                            @foreach(var i in item.multiList.InnerText.Split(',')) {
                                <li>@preValues2.Single(x => x.Id.ToString() == i).Value (#@i)</li>
                            }
                            </ul>
                        </td>
                    </tr>
    
                </table>
            </li>
        }
    </ul>

     

    Many thanks :)

  • Dafydd Owen 33 posts 173 karma points
    May 12, 2014 @ 10:41
    Dafydd Owen
    0

    Sorry for the double post I was researching the forum and found a similar issue back in 2012 http://our.umbraco.org/projects/backoffice-extensions/ucomponents/questionssuggestions/34751-Multiple-Textstring-Error-'string'-does-not-contain-a-definition-for-'InnerText'

    I have tried updating the DLL's using a fresh umbraco installation but still no luck :/

     

     

     

     

     

  • Dafydd Owen 33 posts 173 karma points
    May 12, 2014 @ 11:12
    Dafydd Owen
    100

    ok so I found a solution. I ended using some razor that is different to the examples posted in the uComponents documentation. 
    The code below coverts the id of the dropdown list to the selected value.

    var test = @row.locationsDropdown.Value;
    @umbraco.library.GetPreValueAsString(Convert.ToInt32(test))
    <p>Update here @test</p> 


    It seems so simple now...

Please Sign in or register to post replies

Write your reply to:

Draft