Devexpress MVC GridView / CardView (持续更新)

▼魔方 西西 提交于 2019-11-27 04:12:27

 

//获取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();
        }
}

  

转载于:https://www.cnblogs.com/hesijian/p/9809288.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!