cancel
Showing results for 
Search instead for 
Did you mean: 

How to do default sort in list page

Former Member
0 Kudos

Hi All,

I have one requirement where list has to be display based on a column default sort order. For listing, we will give the column names and the default sort order in ListDef.xml file in <defaultsort> tag.

It is working fine for me if I give the Header item field in <defaultsort> tag. If I give the child item field for sorting, list is not displaying based on this field. After I clicking on the hyper link I could see the values.

Can anybody please tell me how to how to get the default sort eventhough I want to display based on child items.

Thanks in Advance,

Murthy

Accepted Solutions (1)

Accepted Solutions (1)

former_member304703
Contributor
0 Kudos

Hi,

I played with standard MAM list that has similar functionality (NotifPartnerList that has an icon for "delete" column) - works perfectly.

Here are two possible reasons that I can think of:

1. In you code shippet you don't show what is returned else then "inspection.gif". Other icon? Empty string? What do you compare "inspection.gif" with for sorting?

2. When you do changes in ListDef.xml do you remove all *.obj files in folder C:\Program Files\SAP Mobile Infrastructure\data\USER_NAME so taht your new list settings are picked and parsed?

Cheera,

Larissa Limarova

Former Member
0 Kudos

Hi Larissa Limarova,

How is this come, I just changed the return parameter from empty string to some image. Amaging, now default sort is working.

Can you please tell me what was the problem when I used empty string for return parameter when I don't got any values.

Regards,

Murthy.

former_member304703
Contributor
0 Kudos

Hi Murthy,

empty string should work.

I played with standard MAM NotifPartnerList - for "delete" column list displays either no image (empty string is returned by getField method) or delete icon.

So I can not tell you what was your problem.

Regards,

Larissa

Answers (1)

Answers (1)

chintan_virani
Active Contributor
0 Kudos

Narsimha,

U have one list with header and child items or having two lists??

I don't think it is possible to sort the Header based on child.

- Chintan

Former Member
0 Kudos

Hi Chintan,

I have four columns in a list page, where two columns values are comming based on MAM010 (Header items) and two columns values are comming based on MAM010Item010 (child items). Now I need to do the default sorting based on child items.

Regards,

Murthy.

former_member304703
Contributor
0 Kudos

Hi Murthy,

sorting should work fine on any field in the list disregarding where it comes from header/item/other SyncBo.

You can not sort on more than one column though (excerpt "based on child items", can only be one item at a time, not items).

Here is working example code shippets. Sorting field in it comes from other SyncBo but it does not really matter.

zListDef.xml:

<list>

<name>OutstInspNotifList</name>

<maxRowPerPage>15</maxRowPerPage>

<defRowPerPage>10</defRowPerPage>

<maxColPerList>10</maxColPerList>

<managerName>com.sap.mbs.mam.bo.Mam010Manager</managerName>

<managerMethod>getMam010s</managerMethod>

<rowDescriptorMethod>getMam010Descriptor</rowDescriptorMethod>

<ParentBOInterface></ParentBOInterface>

<defaultsort ascending="true">mapSectionComposite</defaultsort>

<linkBuilder>com.ea.mbs.mam.list.link.NotifLinkBuilder</linkBuilder>

<component>notification</component>

<uvmDisplayName>UVM_OUTST_INSP_NOTIF_LIST</uvmDisplayName>

<topline>

<column sortable="true" default="true">

<title>NOTIF_LIST_HD_DISP_MAPSECT</title>

<data type="text">mapSectionComposite</data>

</column>

<column sortable="true" default="true" link="true">

<title>NOTIF_LIST_HD_DISP_POLEID</title>

<data type="text">poleID</data>

</column>

.......

</list>

Sorting field "mapSectionComposite"comes from a characteristic of equipment which is referenced by notification.

Put list in Context for display in custom NotificationList

public Forward onOutstInspNotifListLoad(Forwards forwards) {

BOList dataList = getDataListByType(type);

//dataList is a list of notification for display

setListAttributes(context, notifHeader, dataList, null, null, "onNavigate");

?

public class com.CUSTOMER_EXTENSION.mbs.mam.bo.ext.impl.Mam010Impl extends com.sap.mbs.mam.bo.ext.impl.Mam010Impl {

public Object getField(String key) {

if (key.equals("mapSectionComposite")) {

//PoleId is characteristic "MAPC" in Mam031Item170

if (StringUtility.isEmptyString0((String)super.getField("EQUIPMENT")))

return "";

else {

try {

Mam031 equipment = equipManager.lookupMam031((String)super.getField("EQUIPMENT"));

if (equipment == null) return "";

else {

Condition condition = equipQueryBuilder.getClassificationValueCondition("CHARACT",

RelationalOperatorType.EQUALS, "MAPC");

BOList equipCharacts = (BOList) equipManager.getMam031Item170s(equipment, condition, QueryBuilder.nullSortOrder, QueryBuilder.initialIndex, QueryBuilder.allResultIndex);

if (equipCharacts == null || equipCharacts.size() == 0) return "";

else {

Mam031Item170 equipmentCharacteristic = (Mam031Item170) equipCharacts.get(0);

if (equipmentCharacteristic == null) return "";

else return equipmentCharacteristic.getValueChar();

}

}

} catch (BOException e) {

Log.log(Severities.ERROR, "", e);

return "";

}

}

}

Cheers,

Larissa Limarova

Former Member
0 Kudos

Hi Larissa Limarova,

Thanks for the response. Here I did the same as you said ...

ZlistDef.xml

<list>
        <name>NotifList</name>
        <managerName>com.sap.mbs.mam.bo.Mam010Manager</managerName>
        <managerMethod>getMam010s</managerMethod>
        <rowDescriptorMethod>getMam010Descriptor</rowDescriptorMethod>
        <ParentBOInterface></ParentBOInterface>
        <maxRowPerPage>10</maxRowPerPage>
        <defRowPerPage>5</defRowPerPage>
        <maxColPerList>6</maxColPerList>
        <b> <defaultsort ascending="true">FIELD_VALUE</defaultsort></b> 
        <linkBuilder>com.sap.mbs.mam.list.link.NotifLinkBuilder</linkBuilder>
        <component>notification</component>
        <uvmDisplayName>UVM_NOTIFICATION_LIST</uvmDisplayName>
        <topline>
            <column sortable="true" default="true" link="true">
                <title>NOTIF_LIST_HD_DISP_NOTIF</title>
                <data type="text">NOTIF_NO</data>
                <filterZero>com.sap.mbs.mam.application.filter.impl.NotifNoFilter</filterZero>
            </column>
            <column sortable="true" default="true">
                <title>NOTIF_LIST_HD_DISP_TYPE</title>
                <data type="text">NOTIF_TYPE</data>
            </column>          
             <column sortable="true" default="true">
                <title>STATUS</title>
                <data type="icon">STATUS</data>
            </column>
            <column sortable="true" default="true" link="true">
                <title>ENTRY_LIST</title>
                <data type="icon"><b>FIELD_VALUE</b></data>
            </column>
             </topline>
        <otherline default="true">
            <title>NOTIF_LIST_HD_SHTEXT</title>
            <data type="text">SHORT_TEXT</data>
        </otherline>
    </list>

Sort Field from Mam010Item030Impl which is a child item of MAM010

public class Mam010Impl extends com.sap.mbs.mam.bo.impl.Mam010Impl implements Mam010 {
public Object getField(String key) {
    	

if (key.equals("FIELD_VALUE")) 
		 
		{
			try 
			{
				
				BOList notifID = notifManager.getMam010Item030s(this); 
				mam030 = (Mam010Item030)notifID.get(0);
				fieldVal = mam030.getFieldValue(); 
			} 
			catch(java.lang.ArrayIndexOutOfBoundsException aex)
			{
				
			}
			catch (BOException e)
			{
				
			}
			catch(Exception ee)
			{
				
			}
			
			if((fieldVal=="")||(fieldVal==null)||(fieldVal.equals(null)))
			{
				
				flag = false;
			}
			else
			{
				flag=true;
				imgPath = "mime/inspection.gif";
			}
		
			 return imgPath;
		 }

With this code default sort is not happening.

Can please check my code and let me know where I am doing wrong.

Regards,

Murthy.