Expand my Community achievements bar.

SOLVED

sorting by column in siteadmin

Avatar

Level 4

Hi,

I noticed that when you click on column header inside siteadmin the following command will get posted

http://localhost:4502/content/test/test-basics.pages.json?_dc=1389237752930&sort=assets&dir=ASC&star...

and the json that gets returned will ordered alphanumerically either ASC or DESC.

I have created a new column by implementing the ListInfoProvider interface when I try to order this new column by selecting the header I again see this GET being made

http://localhost:4502/content/test/test-basics.pages.json?_dc=1389237752930&sort=newcolumn&dir=ASC&s...

but the json is not order by the newcolumn.

 

Any help is appreciated

1 Accepted Solution

Avatar

Correct answer by
Level 10

Please refer to this AEM topic that talks about Adding a Custom Column to the Site Admin Console:

http://dev.day.com/docs/en/cq/current/developing/customize_siteadmin.html

You can update the OSGi Jave code to order the custom column. 

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

Please refer to this AEM topic that talks about Adding a Custom Column to the Site Admin Console:

http://dev.day.com/docs/en/cq/current/developing/customize_siteadmin.html

You can update the OSGi Jave code to order the custom column. 

Avatar

Level 4

Hi,

 

How would I order it inside the OSGI code. My understanding is that all data related to the new column gets inserted into the JSONObject info.

Thanks

Avatar

Level 10

As discussed in the AEM docs -- you can work at the Java code level:

package com.test;

import com.day.cq.commons.ListInfoProvider;
import com.day.cq.i18n.I18n;
import com.day.cq.wcm.api.Page;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;

@Component(metatype = false)
@Service(value = ListInfoProvider.class)
public class StarredListInfoProvider implements ListInfoProvider {
     
    private int count = 0;

    public void updateListGlobalInfo(SlingHttpServletRequest request, JSONObject info, Resource resource) throws JSONException {
        info.put("starredCount", count);
        count = 0; // reset for next execution
    }

....

You are correct -- in the updateListGlobalINfo method - you have access to the JSONObject. According to the docs -- info is the JSON object to update, which is respectively the global list or the current list item.

Hope this helps. 

Avatar

Level 10

Another thing to try is to install the sample package that is shown at the end of the AEM doc topic and take a look at it: 

SAMPLE PACKAGE

The outcome of this tutorial is available in the Customizing the Websites Administration Console package on Package Share.