XPage - Sort Column

Hi,

I am trying to allow column sorting on my XPage. I have enabled the sorting (both) in the underlying view.

The icon is displayed and I can click the header, the browser seems to reload the page, but it does not sort the column.

I think I have done everything right, but help would be appreciated.

The sortable column doesn’t need to be the first column…does it??

Thanks

Subject: Re: XPage - Sort Column

No, it doesn’t need to be the first column. I’ve had it working with several columns. The XML that was generated is:

<xp:viewColumn id=“viewColumn2” columnName=“Function” style=“width:75.0px;padding-left:0.0px;padding-right:0.0px”>

<xp:viewColumnHeader value="Function" id="viewColumnHeader2" sortable="true">

</xp:viewColumnHeader>

</xp:viewColumn>

You mentioned that the underlying view design had the columns categorised, which is right. Is this just a flat view? Is the column you’re sorting on just text?

Regards

Paul

Subject: XPage - Sort Column

Thanks for the response.

I have a column in a view called ‘TakenBy’ I want this to be sortable, both ways. This column in the underlying view is Sorted, not categorised - does it need to be categorised too?

Here is my code for the column :

<xp:viewColumn columnName=“Taken By” id=“viewColumn36”>

		<xp:viewColumnHeader value="Taken By" id="viewColumnHeader36" sortable="true">

		</xp:viewColumnHeader>

	</xp:viewColumn>

Yes, its just a flat view and the column value is just text. I have the first column sorted which is used as a key (have a drop down for site which is linked to the sorted first column) - Can you not have more than one column sortable?!?

Oh, and we are using ver. 8.5.1 FP1

Hope this helps.

Jamie

Subject: Re: XPage - Sort Column

The column doesn’t need to be categorised.

Is your drop-down for Site sorting the DominoView data? That might override the subsequent attempt to sort at column level. Or is some code on the load of the page overriding the sort?

What do you have for the xp:dominoView element? If you have a sortColumn or categoryFilter defined there, it might be worth trying without it.

Regards

Paul

Subject: XPage - Sort Column

Here is the code for whole view - hope this helps and thanks for your time :

<xp:viewPanel rows=“15” id=“viewPanel6” pageName=“/en_SupportCall.xsp” viewStyle=“width:100%”>

	<xp:this.facets>

		<xp:pager layout="FirstImage PreviousImage SeparatorPage Group NextImage LastImage" xp:key="headerPager" id="pager6">

		</xp:pager>

		<xp:viewTitle xp:key="viewTitle" id="viewTitle5"><xp:this.value><![CDATA[#{javascript:if(sessionScope.get("site")== "" || sessionScope.get("site")== '')

{

'All Closed Calls - All Sites';

}else

{

'All Closed Calls - ' + sessionScope.get("site")

}

}]]></xp:this.value></xp:viewTitle>

	</xp:this.facets>

	<xp:this.data>

		<xp:dominoView var="closedCallsBySite" viewName="Closed Calls By Site" keys="#{javascript:sessionScope.site}">

		</xp:dominoView>

	</xp:this.data>

	<xp:this.rendered><![CDATA[#{javascript:if(sessionScope.get("view") != 'AllClosedCalls')

{

return false;

}

else{

return true;

}}]]></xp:this.rendered>

	<xp:viewColumn columnName="Site" id="viewColumn33" rendered="false">

		<xp:viewColumnHeader value="Site" id="viewColumnHeader33" sortable="true" rendered="false">

		</xp:viewColumnHeader>

	</xp:viewColumn>

	<xp:viewColumn columnName="Call Number" id="viewColumn34" displayAs="link" openDocAsReadonly="true">

		<xp:viewColumnHeader value="Call Number" id="viewColumnHeader34">

		</xp:viewColumnHeader>

	</xp:viewColumn>

	<xp:viewColumn columnName="Caller" id="viewColumn35">

		<xp:viewColumnHeader value="Caller" id="viewColumnHeader35">

		</xp:viewColumnHeader>

	</xp:viewColumn>

	<xp:viewColumn columnName="Taken By" id="viewColumn36">

		<xp:viewColumnHeader value="Taken By" id="viewColumnHeader36" sortable="true">

		</xp:viewColumnHeader>

	</xp:viewColumn>

	<xp:viewColumn columnName="Call Opened Date" id="viewColumn37">

		<xp:viewColumnHeader value="Call Opened Date" id="viewColumnHeader37">

		</xp:viewColumnHeader>

	</xp:viewColumn>

	<xp:viewColumn columnName="Given To" id="viewColumn38">

		<xp:viewColumnHeader value="Given To" id="viewColumnHeader38">

		</xp:viewColumnHeader>

	</xp:viewColumn>

	

	<xp:viewColumn id="viewColumn6" columnName="Call Closed Date">

		<xp:this.facets>

			<xp:viewColumnHeader xp:key="header"

				id="viewColumnHeader6" value="Call  closed  date">

			</xp:viewColumnHeader>

		</xp:this.facets>

		<xp:this.converter>

			<xp:convertDateTime type="date"></xp:convertDateTime>

		</xp:this.converter>

	</xp:viewColumn></xp:viewPanel>

Subject: Re: XPages sort column

It looks like the problem is the keys. I’ve just tested that on my view, and it prevents the sort. I have a search function for the view as well, and when the search is included, I cannot sort the columns (see code below). I guess the view settings are overriding the sort request from the column. I haven’t been able to get sortColumn and sortOrder to work (last time I looked I couldn’t find any documentation on what allowed values should be), but that might allow you to set the sorting based on a scoped variable. This could work because the sort is on the same element as the keys, the DominoView element. You would need to set the scoped variable from a button rather than the column heading.

<xp:dominoView var=“currentVacancies” viewName=“currentVacancies” searchMaxDocs=“100”>

<xp:this.search><![CDATA[#{javascript:var tmpArray = new Array("");

var cTerms = 0;

if (applicationScope.functionToSearch != null && applicationScope.functionToSearch != “”) {

tmpArray[cTerms++] = "(FIELD Function = \"" + applicationScope.functionToSearch + "\")"

}

if (applicationScope.countryToSearch != null && applicationScope.countryToSearch != “”) {

tmpArray[cTerms++] = "(FIELD Country = \"" + applicationScope.countryToSearch + "\")"

}

qstring = tmpArray.join(" AND ").trim();

return qstring;}]]></xp:this.search>

</xp:dominoView>

Subject: Re: XPages sort column

It looks like it’s a known issue and a tricky one to fix. Just a thought, depending on the size of the view and the amount of sorted columns you want, how about using a repeat control to show the entries for the relevant Site category, using a view where the second column is sorted on TakenBy. Because the repeat control is using a notesViewEntryCollection, the order should be retained. To sort on a different column, you would have to use a different view sorted on that column.

There are probably other options based around getting the relevant documents / note IDs / UNIDs through script and returnito a repeat control.

Regards

Paul