DevExPress控件 客户端常用方法

1 篇文章 0 订阅
1 篇文章 0 订阅

一、aspxmenu和aspxgridview组合

客户端:

function MenuItemClick(s, e) {
    //通过e.item.name来区别由Menu的哪一项来触发
    switch (e.item.name) {
        case "new":
            //新增操作
            grid.AddNewRow();
            break;
        case "edit":
            var index = grid.GetFocusedRowIndex();
            if (index != -1) {
                grid.StartEditRow(index);
            } else {
                alert('请选择要编辑的记录!');
            }
            //编辑操作
            break;
        case "delete":
            var key = grid.GetRowKey(grid.GetFocusedRowIndex());
            if (key != null && key != "") {
                if (window.confirm('你确定要删除这条记录吗?')) {
                    grid.PerformCallback("delete|" + key);
                }
            }
            //删除操作
            break;
        case "select":
            var key = grid.GetRowKey(grid.GetFocusedRowIndex());
            if (key != null && key != "") {
               grid.PerformCallback("select|" + key);
            }
            //删除操作
            break;
        case "refresh":
            grid.PerformCallback("refresh");
            //刷新操作
            break;
        case "export":
            grid.PerformCallback("export");
            alert('PerformCallback:export');
            //刷新操作
            break;
        case "selectall":
            grid.SelectAllRowsOnPage("true");
            alert('selectall');
            //全部选中当前页所有行
            break;
        case "selectallno":
            grid.SelectAllRowsOnPage("false");
            alert('selectallno');
            //全部选中当前页所有行
            break;
    }
}  
function gridrowselect(s, e) {
    var key = grid.GetRowKey(grid.GetFocusedRowIndex());
    if (key != null && key != "") {
       grid.PerformCallback("select|" + key);
    }
}
function EndCallback(s, e) {
    if (s.cp_msg) {
        alert(s.cp_msg);
        s.cp_msg = null;
    }
}
/*aspxtreeview ajax */
function trvofficeClick(s, e) {
    var filter = e.node, text;
    if (e.node.text=="分公司" || e.node.name=="root" || !e.node.parent){
        filter="%";}
        grid.ApplyFilter("科室 like '"+filter+"'");
}
服务端:
 Private Sub ASPxGridView1_CustomDataCallback(sender As Object, e As ASPxGridViewCustomDataCallbackEventArgs) Handles ASPxGridView1.CustomDataCallback
        '可用于前后台的数据传输和回调
        '调用客户端performCallBack方法时触发
        Dim grid As ASPxGridView
        grid = DirectCast(sender, ASPxGridView)

        If e.Parameters.Length <= 0 Then Return
        '分割符号,取决于前台performCallBack方法时触发时格式如
        '前台代码 grid.performcallback('edit|2')
        '前台代码 grid.performcallback('add')
        Dim strParames() As String = e.Parameters.ToString.Split("|")

        '    Dev控件约定,此处添加JSProperties的key,只能以 cp 为前缀。
        Select Case strParames(0).ToLower
            Case "delete"
                Dim id As String = strParames(1) '获取id
            Case "search"
                Dim keys As String = e.Parameters(1)
                grid.Selection.UnselectAll()
                For i As Integer = 0 To grid.VisibleRowCount - 1
                    If grid.GetRowValues(i, "Country") IsNot Nothing Then
                        If (grid.GetRowValues(i, "Country").ToString() = keys) Then
                            grid.Selection.SelectRow(i)
                        End If
                    End If
                Next

            Case "addnew"
                grid.AddNewRow()
            Case "edit"
                If e.Parameters.Length > 1 Then
                    grid.StartEdit(CInt(strParames(1)))
                End If
            Case "copy"
            Case "filter"
            Case "export"
                Dim strdir As String
                strdir = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)


        End Select

    End Sub


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值