I'm using Leblender to insert a filtered list via a control that has a nodepicker and a checkbox list. The nodepicker works nicely, when getting the property by item.GetValue<>
However, I'm trying to do the same for the property based on datatype Checkbox List, with bad results.. It comes back as a json Array with ID's, and I'd like for it to return the actual value, e.g a list of strings.
I actually ended up hardcoding the translation between the ID's in the Json and the actual value that I wanted. It's not the prettiest solution..
What I did was to get the json out like this;
var jsoncategories = item.GetValue("sponsorkategorier");
Newtonsoft.Json.Linq.JArray arraycategories = new Newtonsoft.Json.Linq.JArray();
if (jsoncategories != null) {
arraycategories = (Newtonsoft.Json.Linq.JArray)JsonConvert.DeserializeObject(jsoncategories);
}
And then later I translate this into the strings that I need to use;
foreach (string s in arraycategories)
{
switch (s)
{
case "371":
spcategories.Add("Hovedsponsor");
break;
case "372":
spcategories.Add("Stjernesponsor");
break;
case "373":
spcategories.Add("Kultursponsor");
break;
case "374":
spcategories.Add("Erhvervssponsor");
break;
default:
break;
}
}
Not exactly the perfect solution, since I will have to add a few lines of code if the need to expand the checkbox list should ever arise.
If you crack the code and comes up with a better solution, please let me know.
Checkbox list in leblender grid editor
Hi!
I'm using Leblender to insert a filtered list via a control that has a nodepicker and a checkbox list. The nodepicker works nicely, when getting the property by item.GetValue<>
However, I'm trying to do the same for the property based on datatype Checkbox List, with bad results.. It comes back as a json Array with ID's, and I'd like for it to return the actual value, e.g a list of strings.
How can I accomplish this?
Cheers, Niels
Niels, did you ever figure anything out with this? i am currently struggling with the same. Thanks, Bob
Hey Bob.
I actually ended up hardcoding the translation between the ID's in the Json and the actual value that I wanted. It's not the prettiest solution..
What I did was to get the json out like this;
And then later I translate this into the strings that I need to use;
Not exactly the perfect solution, since I will have to add a few lines of code if the need to expand the checkbox list should ever arise.
If you crack the code and comes up with a better solution, please let me know.
Cheers, Niels
Instead of using the switch statement to extract values, you can try the following to extra values of selected items
is working on a reply...