我正在使用这些代码为每一行写标签。
protected void grd_HtmlRowCreated(object sender, ASPxGridViewTableRowEventArgs e)
{
ASPxLabel lblPoint = grd.FindRowCellTemplateControl(e.VisibleIndex, grdBildiriler.Columns["cTotalValue"] as GridViewDataColumn, "lblPoint") as ASPxLabel;
lblPoint.text = "a value different for each row"
}
我的问题是:如何使用lblPoint.Text启用Column [“cTotalValue”]的排序?
答案 0 :(得分:1)
ASPxGridView有一个可以实现的事件,名为CustomColumnSort。 http://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_CustomColumnSorttopic
protected void grid_CustomColumnSort (object sender, DevExpress.Web.ASPxGridView.CustomColumnSortEventArgs e) {
if (e.Column.FieldName == "cTotalValue")
{
e.Handled = true;
//you can get the row index of 2 columns being sorted through e.ListSourceRowIndex1 and e.ListSourceRowIndex2
//Get the two custom values and compare and set result
var value1 = "Some custom value you retrieve using e.ListSourceRowIndex1";
var value2 = "Another custom value you retrieve using e.ListSourceRowIndex2";
if (value1 > value2)
e.Result = 1;
else if (value1 == value2)
e.Result = Comparer.Default.Compare(value1, value2);
else
e.Result = -1;
}
}