Free Support Forum - aspose.com

Gridweb - How to disable sort

My gridweb allows the user to sort by default. I want to turn that off. I don't want to see the "click to sort" tooltip on the column headings. I don't want the user to be able to click the column and sort the grid results. How do I remove the ability for the user to sort?

This is not related to calling the .sort() method. I am not calling the method. I want to turn off the ability to sort the grid which by default is turned on. I can not find the object or property that allows me to turn sort off.

Hi,


Could you create a sample project, zip it and post it here to show the issue. Also attach some screen shot to highlight the problem, we will look into it and sort it out.

Thank you.

I was assuming that you could simply tell me which object, which property to set to enable/disable the automatic sort feature. Something like “allowSort”. I have been trying to find such a property in your documentation but cannot find it.

Hi,


Sorry for your inconvenience.

We simply import an excel file to the GridWeb and could not find the tool top (“click to sort” etc.) on column headers. Please as I requested, create a sample project, zip it and post it here. Also give some screen shots to highlight it. We will check it as soon as possible.

Thank you.

Attached is a screen snapshot that shows the "click to sort" feature I want to disable.

Also attached is a zipped project which demonstrates that all I did was add the grid and it is giving me the "click to sort" feature automatically. I don't wan the users to be able to sort the grid.

How do I get rid of the "click to sort"?

Here is the .asp:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="dynamicAsposeGridWeb.WebForm1" %>

<%@ Register Assembly="Aspose.Cells.GridWeb" Namespace="Aspose.Cells.GridWeb" TagPrefix="acw" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

<form id="form1" runat="server">

<div>

<acw:gridweb ID="gridWeb1" runat="server"></acw:gridweb>

</div>

</form>

</body>

</html>

Here is the code behind:

using System;

using System.Data;

using System.Data.OleDb;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using Aspose.Cells.GridWeb;

using Aspose.Cells.GridWeb.Data;

namespace dynamicAsposeGridWeb

{

public partial class WebForm1 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (!Page.IsPostBack == true)

{

License license = new License();

license.SetLicense("Aspose.Cells.lic");

String connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Program Files\\Aspose\\Aspose.Cells for .NET\\Demos\\Common\\Database\\demos.mdb";

OleDbConnection conn = new OleDbConnection(connString);

//OleDbCommand cmd = new OleDbCommand("SELECT *, +1 FROM PRODUCTS", conn);

OleDbCommand cmd = new OleDbCommand("SELECT *, -1 FROM PRODUCTS", conn); //<-- this was crashing with previous dll

OleDbDataAdapter da = new OleDbDataAdapter(cmd);

DataSet ds = new DataSet();

conn.Open();

da.Fill(ds, "PRODUCTS");

conn.Close();

WebWorksheet ws = gridWeb1.WebWorksheets[0];

ws.Cells.Clear();

ws.EnableCreateBindColumnHeader = true;

ws.DataSource = ds.Tables[0];

ws.CreateAutoGenratedColumns();

ws.DataBind();

}

}

}

}

Hi,


Thanks for your project.

We understand your requirements. Please use the following lines of code (see the lines of code in bold), I have updated your project/code, please refer to it, it will work as per your needs.

Sample code:

using System;
using System.Data;
using System.Data.OleDb;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Aspose.Cells.GridWeb;
using Aspose.Cells.GridWeb.Data;

namespace dynamicAsposeGridWeb
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack == true)
{
License license = new License();
license.SetLicense(“Aspose.Cells.lic”);

String connString = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:\Program Files (x86)\Aspose\Aspose.Cells for .NET\Demos\Common\Database\demos.mdb”;
OleDbConnection conn = new OleDbConnection(connString);
OleDbCommand cmd = new OleDbCommand(“SELECT *, +1 FROM PRODUCTS”, conn);
//OleDbCommand cmd = new OleDbCommand(“SELECT *, -1 FROM PRODUCTS”, conn); //<-- this crashes
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
conn.Open();
da.Fill(ds, “PRODUCTS”);
conn.Close();

WebWorksheet ws = gridWeb1.WebWorksheets[0];
ws.Cells.Clear();
ws.EnableCreateBindColumnHeader = true;

ws.DataSource = ds.Tables[0];
ws.CreateAutoGenratedColumns();

for (int i = 0; i < ws.BindColumns.Count; i++)
{
ws.BindColumns[i].EnableSort = false;
}

ws.DataBind();
}
}
}
}