修改dataGrid

44 篇文章 0 订阅
3 篇文章 0 订阅

 分页

            pageNo: 1,//优化页码
            pageSize: 20,//优化每页显示条数
        0 < h.length && (0 == b.inputPageNo.length && (c = h.data("pageNo"), h.append('<input id="pageNo" name="pageNo" type="hidden" value="' + (c ? c : b.pageNo) + '"/>'), b.inputPageNo = a("#pageNo", h)), 0 == b.inputPageSize.length && (c = h.data("pageSize"), h.append('<input id="pageSize" name="pageSize" type="hidden" value="' + (c ? c : b.pageSize) + '"/>'), b.inputPageSize = a("#pageSize", h)), 0 == b.inputOrderBy.length && (c = h.data("orderBy"), h.append('<input id="orderBy" name="orderBy" type="hidden" value="' + (c ? c : "") + '"/>'), b.inputOrderBy = a("#orderBy", h)), b.validate &&

 排序

sortableColumn: !1,//优化排序功能
        if (0 < b.columnModel.length) {
            b.colNames = [];
            b.colModel = [];
            c = 0;
            for (var r; c < b.columnModel.length; c++) {
                r = b.columnModel[c];
                r.header ? b.colNames.push(r.header) : r.label && b.colNames.push(r.label);
                if (b.treeGrid || !b.sortableColumn) {
                    //优化排序功能
                    if (r.sortable === undefined) {
                        r.sortable = !1;
                    }
                }
                b.colModel.push(r)
            }
        }
        //优化排序功能
/*
        if (b.treeGrid || !b.sortableColumn) for (c = 0; c < b.colModel.length; c++) b.colModel[c].sortable = !1;
*/

修复ie8下搜索框错位

//重新调整ie8下文本框和标签的长度
if (checkDeviceK().ie !== false && checkDeviceK().ie < 9) {
    $('div[class=form-group]').each(function () {
        var initWidth = $(this).width();
        var labels = $(this).children('label');
        $(this).width(initWidth + getChildrenLabelTotalWidth(labels) + 2)
    });
}

/**
 * 获取元素所有资源色的长度之和
 * @param object
 * @returns {number}
 */
function getChildrenLabelTotalWidth(object) {
    var totalWidth = 0;
    object.each(function () {
        totalWidth = totalWidth + $(this).width();
    });
    return totalWidth;
}

/**
 * 返回设备信息 os和ie和weixin;checkDeviceK.ie
 * @param doc
 */
function checkDeviceK(doc) {
    var n = navigator.userAgent.toLowerCase(), r = function (e) {
        var doc = new RegExp(e + "/([^\\s\\_\\-]+)");
        return e = (n.match(doc) || [])[1], e || !1
    }, o = {
        os: function () {
            return /windows/.test(n) ? "windows" : /linux/.test(n) ? "linux" : /iphone|ipod|ipad|ios/.test(n) ? "ios" : /mac/.test(n) ? "mac" : void 0
        }(), ie: function () {
            return !!(window.ActiveXObject || "ActiveXObject" in window) && ((n.match(/msie\s(\d+)/) || [])[1] || "11")
        }(), weixin: r("micromessenger")
    };
    return doc && !o[doc] && (o[doc] = r(doc)), o.android = /android/.test(n), o.ios = "ios" === o.os, o.mobile = !(!o.android && !o.ios), o
}

优化表格高度

        //优化表格高度
        function n() {
            if (b.autoGridHeight) {
                if ("function" == typeof b.autoGridHeight) var c = b.autoGridHeight(); else {
                    c = a(g).height();
                    var z = a(g).parent();
                    var ss = a(g).parent().parent().parent().parent().parent().height() + 2;
                    //alert(a("body").height());
                    0 != z.length && (c = z.height());
                    c = a(window).height() - /*a("body").height()*/ss + c - b.autoGridHeightFix;
                    200 > c && (c = 200);
                    z.height(c);
                }
                0 != c && g.jqGrid("setGridHeight", c)
            }
        }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
修改DataGrid控件的默认分页样式,可以使用自定义样式和模板。以下是一个示例,展示如何将分页按钮放置在DataGrid控件上方: ```xml <Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <Style x:Key="DataGridStyle" TargetType="{x:Type DataGrid}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGrid}"> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True"> <DockPanel> <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="5"> <Button Content="First" Command="{x:Static DataGridCommands.SelectFirstPage}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" /> <Button Content="Prev" Command="{x:Static DataGridCommands.SelectPreviousPage}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" /> <TextBlock Text="{Binding DisplayTo}" Margin="5" VerticalAlignment="Center" /> <Button Content="Next" Command="{x:Static DataGridCommands.SelectNextPage}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" /> <Button Content="Last" Command="{x:Static DataGridCommands.SelectLastPage}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" /> </StackPanel> <ScrollViewer x:Name="DG_ScrollViewer" Focusable="false"> <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> </ScrollViewer> </DockPanel> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid> <DataGrid Style="{StaticResource DataGridStyle}" /> </Grid> </Window> ``` 在此示例中,我们创建了一个名为DataGridStyle的自定义样式,并将其应用于DataGrid控件。该样式的模板使用DockPanel将分页按钮放置在DataGrid控件的顶部,并使用ScrollViewer包装ItemsPresenter以实现滚动。 您还可以根据需要更改分页按钮的样式和位置,以满足您的具体需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值