Skip to Content
author's profile photo Former Member
Former Member

Change default sort order on search.aspx

I want to change the default sort order on SEARCH.ASPX to sort by part number.

WebTools 2007 is currently sorting the results of a parts search by a weighted index. I want it to sort by part number instead.

I tried to solve this by adding code to control the sorting on the gridview. After the gridview is bound to the data source I want to trigger an event to re-sort it. For this to work I need to get access to the datasource. Is there an API that contains the data source?

This is an extract on my current code.

<asp:GridView ID="PartsListGrid" runat="server"

AutoGenerateColumns="False" Width="100%" OnRowDataBound="PartsListGrid_RowDataBound"

PageSize="50" AllowPaging="True"

OnPageIndexChanging="PartsListGrid_PageIndexChanging"

EmptyDataText="No items were found"

AllowSorting="true"

OnDataBound="CustomersGridView_DataBound"

OnSorting ="PartsListGrid_Sorting" >

<scri pt language="C#" runat=server>

void PartsListGrid_Sorting(object sender, GridViewSortEventArgs e)

{

DataTable m_DataTable = PartsListGrid.DataSource as DataTable;

if (m_DataTable != null)

{

DataView m_DataView = new DataView(m_DataTable);

m_DataView.Sort = e.SortExpression + " ASC";

PartsListGrid.DataSource = m_DataView;

PartsListGrid.DataBind();

}

}

void CustomersGridView_DataBound(Object sender, EventArgs e)

{

PartsListGrid.Sort("Product Code", SortDirection.Descending);

}

</script>

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 02:56 PM

    Hi Thomas,

    The datasouce is netpoint.api.common.NPIndexedSearch.PartSearch(). This method takes a sortexpession argument, so you might be able to manage things this way.

    Alternately, you can try changing the weighted values in the search. Go to Setup->Config Settings in the admin area and try setting all of the "IX" values to 0 except for "IXPartNoWeight".

    There is one other possibly goofy approach you could try. The data for this search is in the NPSearchIndex table. You could probably add a trigger to the table to massage the data to sort the way you want. This method would, at least, not be overwritten during upgrades. I can give you more info on this if you need.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.