zoukankan      html  css  js  c++  java
  • datagrid在MVC中的运用10-勾选

    本文体验与勾选有关的特性。

      需要加载的books.json

    展开

      视图

    展开

    注意:
    如果没有设置 method: 'get',就会报错,因为默认不能以post方式访问静态文件books.json。

    效果:
    check1

    以上没有把books.json中"checked": true的行设置为选中。

      设置每行属性checked为true的行选中

                    onLoadSuccess: function(data) {
                        if (data) {
                            $.each(data.rows, function(index, item) {
                                if (item.checked) {
                                    $('#tt').datagrid('checkRow', index);
                                }
                            });
                        }
                    }

    效果:
    check2

      获取选中行的值

            $(function() {
                initData();
                $('#ButtonGetCheck').click(function() {
                    var checkedItems = $('#tt').datagrid('getChecked');
                    var names = [];
                    $.each(checkedItems, function(index, item) {
                        names.push(item.productname);
                    });
                    console.log(names.join(","));
                });
            });

    效果:
    check3

      /Customer/Index 视图

    展开

    效果:
    check4

    可见,默认状态下:
    可以多选
    勾选会选择行
    选中行会勾选

  • 相关阅读:
    如何在intellj Idea中给新建的项目添加jar包?
    sell
    3D立体方块旋转图册
    npm run eject 命令后出现This git repository has untracked files or uncommitted changes错误
    video标签使用积累+背景视频+遇到问题(视频无法显示,不能自动播放,video自适应div,控件隐藏)
    webpack——react
    webpack——bable-loader,core,preset,编译es6
    webpack——打包JS
    简单的前端上传图片代码
    node——文件写入,文件读取
  • 原文地址:https://www.cnblogs.com/darrenji/p/3577434.html
Copyright © 2011-2022 走看看