Copied to clipboard

Flag this post as spam?

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


  • Ole Martin Bakke 112 posts 624 karma points
    Dec 22, 2014 @ 21:08
    Ole Martin Bakke
    0

    Value from json property editor in list view

    Hi!

    I've created a property editor which stores it'a value as json.
    (http://our.umbraco.org/projects/website-utilities/ksumbraco7calendar)

    If I select to show this data type in the list view the whole json is viewed. Is it possible to define a property from the json to view in the listview? The json would look something like this: {"recurrence":"1","weekInterval":"1","monthYearOption":"1","interval":"1","weekDay":"1","month":"1","monthOption":"1","startDate":"2014-12-22 21:00","endDate":"2014-12-23 21:00"}

    And i would like to show the value for startDate.


    Thanks!

    Ole Martin

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Dec 22, 2014 @ 21:34
    Dennis Aaen
    0

    Hi Ole Martin,

    If I understand your questions correctly then you are using the http://our.umbraco.org/projects/website-utilities/ksumbraco7calendar package on your project and now you want to display the start date value.

    Did you see the pdf with the documentation if not take a look here /FileDownload?id=12113, there is an example on how to show the start date.

    Hope this helps,

    /Dennis

     

  • Ole Martin Bakke 112 posts 624 karma points
    Dec 22, 2014 @ 21:41
    Ole Martin Bakke
    0

    No, I'll try to reformulate the question.

    I am making a custom propery editor, which stores its value as JSON.

    Using the new List view in Umbraco 7.2.1 it's possible to add custom columns to the list view.

    I am wondering if it's possible in a custom property editor (e.g. in the package.manifest) to define a value to show if the data type is viewed in the list view as a custom column.

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Jun 15, 2015 @ 12:28
    Markus Johansson
    0

    Any solution to this issue so far?

  • Ole Martin Bakke 112 posts 624 karma points
    Jun 15, 2015 @ 12:47
    Ole Martin Bakke
    0

    No, I haven't found any solution to this yet. On the old download-page I read that in version 7.3 it sould be possible to sort by custom properties. (Ref.: http://issues.umbraco.org/issue/U4-6003) So I will wait until that release to see whats possible. An alternative for me is to save one JSON-attribute in an other property type and sort by that.

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Jun 15, 2015 @ 12:54
    Markus Johansson
    0

    That's sorting by the property - but nothing about fetching a property from a json-blob?

  • Ole Martin Bakke 112 posts 624 karma points
    Jun 15, 2015 @ 12:58
    Ole Martin Bakke
    0

    That's right. But it's one step in the right direction... So I will wait and see what possibilities that will bring. Maybe an event to hook into or something.

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Jun 15, 2015 @ 13:19
    Markus Johansson
    0

    Did you post anything on issue.umbraco.org for this? I can do that otherwise?

  • Ole Martin Bakke 112 posts 624 karma points
    Jun 15, 2015 @ 13:22
    Ole Martin Bakke
    0

    No, I didn't. If you do, please post the url/issueno here, so I can follow it.

  • Markus Johansson 1902 posts 5706 karma points MVP c-trib
    Jun 15, 2015 @ 14:08
    Markus Johansson
    0

    Here: http://issues.umbraco.org/issue/U4-6706

    Please add info and vote =D

  • Simon Czerwinski 14 posts 107 karma points
    Apr 17, 2020 @ 19:14
    Simon Czerwinski
    0

    Hey!

    I have the same problem like you guys but it seems that the solution for this isn't here. I searched in the URL Markus posted to but no luck..

    I use the Umbraco Gmaps plugin which has some great solution to choose a specific place in a nice way..

    enter image description here

    I then use this method in a list view with items who has their own "google maps" property.
    I then wanted to sort all the items by address and city in the list view, see the screenshot down below:

    enter image description here

    Here I have the google maps data property in the list view, it's returning everything in a JSON string..

    I don't know how to the extract address and city.. Any idea? Did you find a way? I know this post is like 6 years old, but I'll give it a try! :D

    Best regards,

    Simon

  • Ole Martin Bakke 112 posts 624 karma points
    Apr 29, 2020 @ 09:48
    Ole Martin Bakke
    0

    Hi, What I did was to create another property on the document type, eg. a label. Then I wrote some code that extracted the value I wanted to show in the listview and saved it to that label. Here is some sample-code. I haven't tested this exact code, and you will have to edit it to suit your needs and aliases.

    public class CustomEventHandler : ApplicationEventHandler
    {
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            ContentService.Saving += ContentService_Saving;
        }
    
    void ContentService_Saving(IContentService sender, Umbraco.Core.Events.SaveEventArgs<IContent> e)
    {
        if (UmbracoContext.Current == null) return;
        foreach (var node in e.SavedEntities)
        {
            try
            {
                if (node.DocumentTypeAlias == "YourDocumentType"))
                {
                    var value = ""; //Extract the address here...
                    node.SetValue("LabelField", value);
                    sender.Save(node, currentUser?.Id ?? 0, false);
    
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error<CustomEventHandler>("Could not save events for node.", ex);
            }
        }
    }
    

    }

Please Sign in or register to post replies

Write your reply to:

Draft