回复 1楼mountain2657的帖子
后台代码如下:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- return;
- }
- this.FpSpread1.ActiveSheetView.AllowSort = true;
- this.FpSpread1.ActiveSheetView.Cells[0, 0].Value = 2;
- this.FpSpread1.ActiveSheetView.Cells[1, 0].Value = 1;
- this.FpSpread1.ActiveSheetView.Cells[2, 0].Value = 3;
- this.FpSpread1.ActiveSheetView.ColumnHeader.Rows.Count = 2;
- }
- protected override void Render(HtmlTextWriter writer)
- {
- Table cheader = this.FpSpread1.FindControl("cht") as Table;
- int rowcount = 0;
- int colcount = 0;
- if (cheader != null)
- {
- rowcount = cheader.Rows.Count;
- colcount = cheader.Rows[0].Cells.Count;
- }
- //点击第一行出发排序
- for (int j = 0; j < colcount; j++)
- {
- cheader.Rows[0].Cells[j].Attributes.Add("onclick", "sortcolumn()");
- }
- base.Render(writer);
- }
复制代码
前台代码:
- <script type="text/javascript">
- function sortcolumn() {
- var spread = this.document.getElementById("FpSpread1");
- var activeCol = spread.GetActiveCol();
- spread.SortColumn(activeCol);
- }
- function test() {
- var spread = this.document.getElementById("FpSpread1");
- var activeCol = spread.GetActiveCol();
- spread.SortColumn(activeCol);
- }
- </script>
复制代码 |