radgridview.TableElement.Update不;不起作用
本文关键字:不起作用 Update TableElement radgridview | 更新日期: 2023-09-27 18:27:12
我正在尝试使用contextMenu上的事件更新我的网格视图。但它不起作用。。
这是我的代码:
行格式化
void dgItemList_RowFormatting(object sender, RowFormattingEventArgs e)
{
ItemModel rowModel = e.RowElement.RowInfo.DataBoundItem as ItemModel;
if (rowModel.Status == 2)
{
e.RowElement.ForeColor = Color.Red;
}
}
点击事件
void Deactivate_Click(object sender, EventArgs e)
{
GridViewRowInfo row = dgItemList.CurrentRow;
ItemModel rowModel = row.DataBoundItem as ItemModel;
if(UiHelpers.ShowConfirmForm("Do you want to Deactivate this Item?"))
{
ServiceResult result = _svc.UpdateItemStatus(rowModel.ItemID);
if(result.Successful)
{
UiHelpers.ShowSuccessForm(rowModel.Description + " was successfully deactivated!");
dgItemList.TableElement.Update(GridUINotifyAction.StateChanged);
}
}
}
我正在使用.TableElement.Update()
来运行rowFormatting
。。但是它不起作用。。。功能CCD_ 3只是将项目的状态改变为CCD_。我真的是新手,所以请耐心等待。
我用的是C#和Telerik。
除了确保设置了状态之外,我还建议使用
row.InvalidateRow()
方法,它只会使一行无效,而TableElement.Update是较重的更新。
此外,在RowFormatting处理程序中,您还必须重置引入的外观修改,因为网格使用虚拟化,并且元素在滚动、过滤等操作中被重用:
void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
{
if (e.RowElement.RowInfo.Cells[0].Value.ToString().Contains("3"))
{
e.RowElement.DrawFill = true;
e.RowElement.BackColor = Color.Yellow;
e.RowElement.GradientStyle = GradientStyles.Solid;
}
else
{
e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
}
关于行格式化的更多信息可以在这里找到:链接。在这里,您可以阅读有关UI虚拟化的信息:链接