private void sgc1_LoadVirtualRow(object sender, DevComponents.DotNetBar.SuperGrid.GridVirtualRowEventArgs e)
{
//排序
try
{
GridPanel sgc1gridpanel = e.GridPanel;
foreach (var column in sgc1gridpanel.SortColumns)
{
if (column.SortDirection==DevComponents.DotNetBar.SuperGrid.SortDirection.Ascending)
{
dv.Sort = column.Name + " desc";
}
else
{
dv.Sort = column.Name + " asc";
}
}
DT = dv.Table;
}
catch (Exception r)
{
return;
}
//数据填充
try
{
using (DevComponents.DotNetBar.SuperGrid.GridRow row = e.GridRow)
for (int i = 0; i < DT.Columns.Count; i++)
{
row.Cells[i].Value = dv[row.Index][i];
}
}
catch (Exception r)
{
return;
}
}
/// <summary>
/// 数据筛选
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void sgc1_FilterEditValueChanged(object sender, DevComponents.DotNetBar.SuperGrid.GridFilterEditValueChangedEventArgs e)
{
try
{
string s_where = "";
GridPanel sgc1panel = sgc1.PrimaryGrid;
string ls_columname1 = "";
//遍历所有筛选栏
foreach (GridColumn column in sgc1panel.Columns)
{
int li_co_in = column.ColumnIndex;
string ls_columname = column.Name;
//当前操作栏位需获取编辑后数据,因此单独列出
if (column == e.GridColumn)
{
if (e.NewExpr != null)
{
ls_columname1 = (string)e.NewValue;
if (DT.Columns[column.ColumnIndex].DataType == Type.GetType("System.Int") || DT.Columns[column.ColumnIndex].DataType == Type.GetType("System.Int16") || DT.Columns[column.ColumnIndex].DataType == Type.GetType("System.Int32") || DT.Columns[column.ColumnIndex].DataType == Type.GetType("System.Decimal") || DT.Columns[column.ColumnIndex].DataType == Type.GetType("System.Long"))
{
s_where += " and " + ls_columname + " = " + "" + ls_columname1 + "";
}
else
{
s_where += " and " + ls_columname + " like " + "'%" + ls_columname1 + "%'";
}
}
}
//其余栏位获取历史数据即可
else
{
if (column.FilterExpr != null)
{
ls_columname1 = (string)column.FilterValue;
if (DT.Columns[column.ColumnIndex].DataType == Type.GetType("System.Int") || DT.Columns[column.ColumnIndex].DataType == Type.GetType("System.Int16") || DT.Columns[column.ColumnIndex].DataType == Type.GetType("System.Int32") || DT.Columns[column.ColumnIndex].DataType == Type.GetType("System.Decimal") || DT.Columns[column.ColumnIndex].DataType == Type.GetType("System.Long"))
{
s_where += " and " + ls_columname + " = " + "" + ls_columname1 + "";
}
else
{
s_where += " and " + ls_columname + " like " + "'%" + ls_columname1 + "%'";
}
}
}
}
dv = DT.DefaultView;
dv.RowFilter = "1=1" + s_where;
this.sgc1.PrimaryGrid.Rows.Clear();
this.sgc1.PrimaryGrid.VirtualRowCount = dv.Count;
}
catch (Exception r)
{
return;
}
}
VirtualModel数据填充排序与筛选
最新推荐文章于 2022-11-30 15:06:44 发布