Devexpress MVC GridView / CardView (持续更新)

 

//获取gridview里面的combo box 显示的文本
//获取某个column在gridview的 index 
 RightGridView.GetColumnByField("FunUID").index
//获取gridview里面的combo box 显示的文本
RightGridView.batchEditHelper.GetCellTextContainer(visibleindex ,columnIndex).textContent

  

在Double Click event里面. 获取当前鼠标选择的列的值
在Double Click event里面. 获取当前鼠标选择的值
//s.GetFocusedCell().rowVisibleIndex 获取当前选中行的index
//s.GetFocusedCell().column.fieldName 获取当前选中行的field
s.batchEditApi.GetCellValue(s.GetFocusedCell().rowVisibleIndex,s.GetFocusedCell().column.fieldName) 

  

//自定义计算footer的summary 
  
//自定义计算footer的summary 
//首先将需要自定义计算的field 设置为 DevExpress.Data.SummaryItemType.Custom

settings.CustomSummaryCalculate = (s, e) =>
        {

            ASPxSummaryItem summary = e.Item as ASPxSummaryItem;
            if (e.IsTotalSummary)
            {

                int li_totalValue = 0;
                decimal ld_totalValue = 0;
                for (int i = 0; i < ((MVCxGridView)s).VisibleRowCount; i++)
                {
                    if (summary.FieldName == "QTY")
                    {
                        if ((((MVCxGridView)s).GetRowValues(i, "TranType") == DBNull.Value ? "" : ((MVCxGridView)s).GetRowValues(i, "TranType").ToString()) == "IN")
                            li_totalValue += Convert.ToInt32(((MVCxGridView)s).GetRowValues(i, "QTY"));
                        else
                            li_totalValue -= Convert.ToInt32(((MVCxGridView)s).GetRowValues(i, "QTY"));
                        e.TotalValue = li_totalValue;
                    }
                }
                e.TotalValueReady = true;
            }
        };

  

  

//在Column里面显示Button(包含当添加新行时无法触发onclick event)
//在Column里面显示Button(包含当添加新行时无法触发onclick event)
partial view

   settings.Columns.Add(column =>
        {
            column.Caption = "...";
            column.FieldName = "btnDlvAddress";
            column.UnboundType = DevExpress.Data.UnboundColumnType.String;
            column.Width = 50;
            column.SetDataItemTemplateContent(container =>
            {

                Html.DevExpress().Button(b =>
                {
                    b.Name = "btnDlvAddress" + container.KeyValue;
                    b.Text = "...";
                    b.Width = Unit.Percentage(100);
                    b.ClientSideEvents.Click = "function(s,e){ OnSearchDlvAddress(); }";
                    b.ClientEnabled = true;
                    b.EnableClientSideAPI = true;
                    b.ClientVisible = true;
                }).Render();

            });
        });



Index.cshtml

function OnSearchDlvAddress()
{

}

//使用Gridview的StartEdit event 处理当时新行的时候 call function
 function OnTruReqGridView_BatchStartEdit(s,e)
    {
        e.cancel = true;
    if(e.focusedColumn.fieldName == "btnDlvAddress")
        {
            e.cancel = true;
            if(ModalTruReqGridView.batchEditApi.IsNewRow(e.visibleIndex))
                OnSearchDlvAddress();
        }
}

  

 

//判断Gridview里面某行的某列是否有修改

//agdv_Grid.batchEditApi.HasChanges(行号, 列名orID)
var lb_IsEdit = Gridview.batchEditApi.HasChanges(0, "ColumnName");

//lb_IsEdit 将返回true or false

  

posted @ 2018-10-18 11:03  Jack He  阅读(1644)  评论(0编辑  收藏  举报