I have a datatype using the property editor Multiple Textbox. I use this in Grid Editors created with LeBlender and in the admin it's working fine. But I have an issue to display the values of the different textboxes in the frontend.
The code I use is:
@if (Model.Items.Any())
{
<ul>
@foreach (var item in Model.Items)
{
var advantages = item.GetValue("advantage");
foreach (var vid in advantages)
{
<li>@vid</li>
}
}
</ul>
}
The output I get is a list with in every li one character of System.String[]
I tried some things to get the correct result but I only got a variation on the display of System.String[]. So I'm a little bit clue less for the moment.
Is it possible to use Multiple Textbox in combination with LeBlender?
If yes, how can I get the value of every textbox?
GetPropertyValue doesn't work in this case.
item is in my example code from the type LeBlenderValue so a specific type from LeBlender.
I can pass also the type when using the GetValue function of LeBlender.
If I use item.GetValue< String[] >("advantage"); (also without the spaces before and after String[] ;-)) than the result is.
Thanks Steve but I'm afraid that your solution will not work.
I'm using the property editor Multiple Textbox (new in Umbraco 7)
Maybe this is so new that LeBlender not yet support this.
This means that there is a single document type "advantage" in my example. That can contain dynamically multiple values (one for every textbox the content editor can add). That's the reason why I try to use the second for each.
If I don't get it working than I will probably switch to a normal text string. The content editor can add than also multiple textboxes but I had the feeling that this was a little bit more user-friendly with Multiple Textbox.
Thanks Steve! You are my hero of the day :-)
It's indeed working when using the Newtonsoft.Json.Linq.JArray
It is possible that when we use the Multiple Textbox as a 'normal' document type that it will be indeed a string array. But that LeBlender did a convert to JArray. Anyway I have now a nice li list with the values of the Multiple Textbox in my grid.
How to use Multiple Textbox
I have a datatype using the property editor Multiple Textbox. I use this in Grid Editors created with LeBlender and in the admin it's working fine. But I have an issue to display the values of the different textboxes in the frontend.
The code I use is:
The output I get is a list with in every li one character of System.String[]
I tried some things to get the correct result but I only got a variation on the display of System.String[]. So I'm a little bit clue less for the moment.
Is it possible to use Multiple Textbox in combination with LeBlender? If yes, how can I get the value of every textbox?
Not used LeBlender but does this work?:
var advantages = item.GetPropertyValue
Failing that - are you running Visual Studio - stick a breakpoint on that line and inspect advantages.
Hmm... that line should be (without the spaces before and after String[]:
var advantages = item.GetPropertyValue< String[] >("advantage");
The forum formatting code seems to have changed it.
GetPropertyValue doesn't work in this case.
item is in my example code from the type LeBlenderValue so a specific type from LeBlender.
I can pass also the type when using the GetValue function of LeBlender. If I use item.GetValue< String[] >("advantage"); (also without the spaces before and after String[] ;-)) than the result is.
So I think that the trick is to find the good type to pass but I don't have any idea what I could use.
HI,
Had a quick look at this. Not sure what the Lecoati foreach does but... you just need to GetValue
e.g. I created three mutli text strings called "text1", "text2", "text3" and this outputs all of my strings.
Hope that helps.
Thanks Steve but I'm afraid that your solution will not work.
I'm using the property editor Multiple Textbox (new in Umbraco 7)
Maybe this is so new that LeBlender not yet support this.
This means that there is a single document type "advantage" in my example. That can contain dynamically multiple values (one for every textbox the content editor can add). That's the reason why I try to use the second for each.
If I don't get it working than I will probably switch to a normal text string. The content editor can add than also multiple textboxes but I had the feeling that this was a little bit more user-friendly with Multiple Textbox.
Sorry - I'd never seen that Multi Textbox datatype before!
The (incomplete) documentation suggests that it should return a string array.
It actually returns a JArray... so this should work.
@inherits UmbracoViewPage
}
GRRR
The forum is stuffing the code again.
Thanks Steve! You are my hero of the day :-) It's indeed working when using the Newtonsoft.Json.Linq.JArray
It is possible that when we use the Multiple Textbox as a 'normal' document type that it will be indeed a string array. But that LeBlender did a convert to JArray. Anyway I have now a nice li list with the values of the Multiple Textbox in my grid.
No problem - glad to be of help!
Sorry for taking this topic up again but, thanks Steve! :-)
I got the same problem but your solution worked! :-)
is working on a reply...