KendoUI:Grid控件的使用

时间:2025-02-15 08:04:44
  • var codeGridSource = new (
  • {
  • transport : {
  • read : function(options) {
  • var map = {};
  • if ()
  • = ;
  • if ()
  • = ;
  • if ()
  • = ;
  • if ()
  • = ;
  • if (!){
  • }
  • else
  • {
  • = {
  • logic : "and",
  • filters : [
  • {
  • field : "codeName",
  • value : $("#codeName").val()
  • },
  • {
  • field : "codeType",
  • value : $("#codeType").val()
  • },
  • {
  • field : "codeTypeName",
  • value : $("#codeTypeName").val()
  • },
  • {
  • field : "codeCode",
  • value : $("#codeCode").val()
  • }
  • ]};
  • var fi1 = {};
  • var fi2 = [];
  • var j = 0;
  • $.each(, function(i,element) {
  • if ([i].value)
  • {
  • fi2[j] = [i];
  • j++;
  • }
  • });
  • if ( > 0)
  • {
  • = fi2;
  • = ;
  • = fi1;
  • }
  • }
  • //排序
  • if (!)
  • {
  • }
  • else
  • {
  • = [
  • {
  • field : $("#codeOrder0").val(),
  • dir : $("#codeDir0").val()
  • },
  • {
  • field : $("#codeOrder1").val(),
  • dir : $("#codeDir1").val()
  • }
  • ];
  • var fi3 = [];
  • var j = 0;
  • $.each(, function(i,element){
  • if ([i].field) {
  • fi3[j] = [i];
  • j++;
  • }
  • });
  • if ( > 0)
  • {
  • = fi3;
  • }
  • }
  • $.ajax({
  • url : "code/",
  • dataType: "json",
  • data:{
  • models : (map)
  • },
  • type:"POST",
  • success: function(result) {
  • (result);
  • },
  • error: function(result) {
  • (result);
  • }
  • });
  • },
  • update : function(options) {
  • $.ajax({
  • url : "code/",
  • dataType: "json",
  • data:{
  • models : ()
  • },
  • type:"POST",
  • success: function(result) {
  • (result);
  • },
  • error: function(result) {
  • (result);
  • }
  • });
  • },
  • destroy : function(options) {
  • $.ajax({
  • url : "code/",
  • dataType: "json",
  • data:{
  • models : ()
  • },
  • type:"POST",
  • success: function(result) {
  • (result);
  • },
  • error: function(result) {
  • (result);
  • }
  • });
  • },
  • create : function(options) {
  • $.ajax({
  • url : "code/",
  • dataType: "json",
  • data:{
  • models : ()
  • },
  • type:"POST",
  • success: function(result) {
  • (result);
  • },
  • error: function(result) {
  • (result);
  • }
  • });
  • }
  • },
  • batch : true,
  • pageSize : 8,
  • serverPaging : true,
  • serverSorting : true,
  • serverFiltering : true,
  • schema : {
  • errors: function(response)
  • {
  • return ;
  • },
  • data : "list",
  • total : "total",
  • model : {
  • id : "id",
  • fields :
  • {
  • codeIndex:
  • {
  • editable : true,
  • type:"number",
  • defaultValue: 0,
  • validation:{
  • required:true,
  • min:0
  • }
  • },
  • codeCode :
  • {
  • editable : true,
  • type:"string",
  • validation:
  • {
  • codeCodevalidation: function (input)
  • {
  • if (("[name=codeCode]") && $.trim(()) == "" )
  • {
  • ("data-codeCodevalidation-msg", "请输入业务代码!");
  • ("border-color","red");
  • return false;
  • }
  • else{
  • ("border-color"," #94C0D2");
  • }
  • return true;
  • }
  • }
  • },
  • codeName :
  • {
  • editable : true,
  • type:"string"
  • },
  • codeType :
  • {
  • editable : true,
  • type:"string",
  • validation:
  • {
  • codeTypevalidation: function (input)
  • {
  • if (("[name=codeType]") && $.trim(()) == "")
  • {
  • ("data-codeTypevalidation-msg", "请输入代码类型!");
  • ("border-color","red");
  • return false;
  • }
  • else{
  • ("border-color"," #94C0D2");
  • }
  • return true;
  • }
  • }
  • },
  • codeTypeName:
  • {
  • editable : true,
  • type:"string"
  • }
  • }
  • }
  • },
  • error: function(e) {
  • alert(); // displays "Invalid query"
  • ();
  • }
  • });