0】绑定数据

grid = $("#Grid").datagrid({
fit: true,
rownumbers: true,
fitColumns: true,
height: $(window).height() * 0.8,
singleSelect: false,
columns: [[
{ field: "ck", checkbox: true },
{ field: "Name", title: "用户名", width: 50, sortable: true },

]],
url: "/Admin/UserInfo/测试",

});

1】先定义一个数组

var All_commentUserArr = new Array();

2】给数组添加数据

var crows = $('#Grid').datagrid("getSelections");
if (crows.length > 0) {
for (var i = 0; i < crows.length; i++) {
var o = new Object();
o.Id = crows[i].Id;
o.Name = crows[i].Name;
All_commentUserArr.push(o);//这一步是添加数据
}
}

3】删除数据(根据选择的)

var crows = $('#Grid').datagrid("getSelections");
//先删除数组中所有数据当前单位的数据
if (crows.length > 0) {
for (var i = 0; i < crows.length; i++) {
for (var j = 0; j < All_commentUserArr.length; j++) {
if (All_commentUserArr[j] == crows[i]) {
var index = All_commentUserArr.indexOf(crows[i]);
if (index > -1) {
All_commentUserArr.splice(index, 1);
}
break;
}
}
}
}
createSelectGrid(All_commentUserArr);

js中json的添加和指定位置的删除的更多相关文章

  1. js 中json遍历 添加 修改 类型转换

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  2. js中Json字符串如何转成Json对象(4种转换方式)

    js中Json字符串如何转成Json对象(4种转换方式) 一.总结 一句话总结:原生方法(就是浏览器默认支持的方法) 浏览器支持的转换方式(Firefox,chrome,opera,safari,ie ...

  3. js中JSON的解析(将json字符串转化为对象)和序列化(将对象转化为json字符串)(函数的功能一般都挺全的,需要的时候去查看完整函数)

    js中JSON的解析(将json字符串转化为对象)和序列化(将对象转化为json字符串)(函数的功能一般都挺全的,需要的时候去查看完整函数) 一.总结 1.JSON解析:JSON.parse(myJS ...

  4. js中json数据简单处理(JSON.parse()和js中嵌套html)

    js中json数据简单处理(JSON.parse()和js中嵌套html) 一.总结 1.html中嵌套js:<script>js代码</script> 2.js中嵌套html ...

  5. js中json法创建对象(json里面的:相当于js里面的=)

    js中json法创建对象(json里面的:相当于js里面的=) 一.总结 json里面的:相当于js里面的= 4.json创建js对象解决命名冲突:多个人为同一个页面写js的话,命名冲突就有可能发生, ...

  6. js中 json对象与json字符串相互转换的几种方式

    以下总结js中 json对象与json字符串相互转换的几种方式: 一.JSON对象转化为JSON字符串 1.使用JSON.stringify()方法进行转换 该方法不支持较老版本的IE浏览器,比如:i ...

  7. php和js中json的编码和解码

    php中 1)编码 $jsonStr = json_encode($array) 2)解码 $arr = json_decode($jsonStr) <?php echo json_encode ...

  8. js中json的转换

    //aa='{"id":0,"appId":"app***********Id","appSecret":"a ...

  9. Js中JSON.stringify()与JSON.parse()与eval()详解及使用案例

    JSON(JavaScript Object Notation)是一种轻量级的数据交换格式.因为采用独立于语言的文本格式,也使用了类似于C语言家族的习惯,拥有了这些特性使使JSON称为理想的数据交换语 ...

随机推荐

  1. Java-IO 字节流的使用和效率比较

    打算做一个系列,前面讲了基本的字符流的用法,这篇博客介绍一下字节流的基本用法: 一.基本使用: 基本字节流: FileInputStream   FileOutputStream BufferedIn ...

  2. python学习相关知识点

    1.ndarray中,添加行或列:https://blog.csdn.net/lishuandao/article/details/52444288 2.numpy中ndarray数组拼接方法介绍:h ...

  3. Java线程安全相关概

  4. 让 ComboBox 的每个栏目显示不同颜色

    在一般的应用程式中,使用 ComboBox 提供下拉选单的功能,让使用者选择不同项目,一般而言, ComboBox 的项目没有什么特别的,但在特定的应用程式中,有时候会希望每个项目有一些效果呈现,例如 ...

  5. Http 1.x弊端与Http 2.0比较

    HTTP2.0作为新版协议,改动细节必然很多,不过对应用开发者和服务提供商来说,影响较大的就几点. 新的二进制格式(Binary Format) http1.x诞生的时候是明文协议,其格式由三部分组成 ...

  6. SUSE12SP3-Mysql5.7安装

    1.将以下安装包复制到服务器 mysql-community-client-5.7.24-1.sles12.x86_64.rpm mysql-community-server-5.7.24-1.sle ...

  7. [Swift]LeetCode64. 最小路径和 | Minimum Path Sum

    Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...

  8. [Swift]LeetCode363. 矩形区域不超过 K 的最大数值和 | Max Sum of Rectangle No Larger Than K

    Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix s ...

  9. [Swift]LeetCode730. 统计不同回文子字符串 | Count Different Palindromic Subsequences

    Given a string S, find the number of different non-empty palindromic subsequences in S, and return t ...

  10. [Swift]LeetCode939. 最小面积矩形 | Minimum Area Rectangle

    Given a set of points in the xy-plane, determine the minimum area of a rectangle formed from these p ...