欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery Easyui datagrid editor為combobox時(shí)指定數(shù)據(jù)源實(shí)例

 更新時(shí)間:2016年12月19日 14:46:48   作者:garfieldzf  
當(dāng)在datagrid行內(nèi)部應(yīng)用添加編輯操作時(shí),引入combobox是非常方便的操作,這篇文章主要介紹了jQuery Easyui datagrid editor為combobox時(shí)指定數(shù)據(jù)源實(shí)例,有興趣的可以了解一下。

當(dāng)在datagrid行內(nèi)部應(yīng)用添加編輯操作時(shí),引入combobox是非常方便的操作,我在引入combobox時(shí)對數(shù)據(jù)源這快做個(gè)總結(jié),在做demo的過程中遇到個(gè)問題,就是當(dāng)你選擇了下拉框的值后點(diǎn)擊保存,此時(shí)顯示的是value值,而不是text值,這時(shí)使用格式化函數(shù)解決此問題。

var Address = [{ "value": "1", "text": "CHINA" }, { "value": "2", "text": "USA" }, { "value": "3", "text": "Koren" }];

function unitformatter(value, rowData, rowIndex) {

  if (value == 0) {

    return;

  }

 

  for (var i = 0; i < Address.length; i++) {

    if (Address[i].value == value) {

      return Address[i].text;

    }

  }

}

function GetTable() {

  var editRow = undefined;

  $("#Student_Table").datagrid({

    height: 300,

    width: 450,

    title: '學(xué)生表',

    collapsible: true,

    singleSelect: true,

    url: '/Home/StuList',

    idField: 'ID',

    columns: [[

     { field: 'ID', title: 'ID', width: 100 },

      { field: 'Name', title: '姓名', width: 100, editor: { type: 'text', options: { required: true } } },

      { field: 'Age', title: '年齡', width: 100, align: 'center', editor: { type: 'text', options: { required: true } } },

      { field: 'Address', title: '地址', width: 100, formatter: unitformatter, align: 'center', editor: { type: 'combobox', options: { data: Address, valueField: "value", textField: "text" } } }

    ]],

    toolbar: [{

      text: '添加', iconCls: 'icon-add', handler: function () {

        if (editRow != undefined) {

          $("#Student_Table").datagrid('endEdit', editRow);

        }

        if (editRow == undefined) {

          $("#Student_Table").datagrid('insertRow', {

            index: 0,

            row: {}

          });

          $("#Student_Table").datagrid('beginEdit', 0);

          editRow = 0;

        }

      }

    }, '-', {

      text: '保存', iconCls: 'icon-save', handler: function () {

        $("#Student_Table").datagrid('endEdit', editRow);

        //如果調(diào)用acceptChanges(),使用getChanges()則獲取不到編輯和新增的數(shù)據(jù)。

        //使用JSON序列化datarow對象,發(fā)送到后臺(tái)。

        var rows = $("#Student_Table").datagrid('getChanges');

        var rowstr = JSON.stringify(rows);

        $.post('/Home/Create', rowstr, function (data) {

        });

      }

    }, '-', {

      text: '撤銷', iconCls: 'icon-redo', handler: function () {

        editRow = undefined;

        $("#Student_Table").datagrid('rejectChanges');

        $("#Student_Table").datagrid('unselectAll');

      }

    }, '-', {

      text: '刪除', iconCls: 'icon-remove', handler: function () {

        var row = $("#Student_Table").datagrid('getSelections');

      }

    }, '-', {

      text: '修改', iconCls: 'icon-edit', handler: function () {

        var row = $("#Student_Table").datagrid('getSelected');

        if (row != null) {

          if (editRow != undefined) {

            $("#Student_Table").datagrid('endEdit', editRow);

          }

          if (editRow == undefined) {

            var index = $("#Student_Table").datagrid('getRowIndex', row);

            $("#Student_Table").datagrid('beginEdit', index);

            editRow = index;

            $("#Student_Table").datagrid('unselectAll');

          }

        } else {

        }

      }

    }, '-', {

      text: '上移', iconCls: 'icon-up', handler: function () {

        MoveUp();

      }

    }, '-', {

      text: '下移', iconCls: 'icon-down', handler: function () {

        MoveDown();

      }

    }],

    onAfterEdit: function (rowIndex, rowData, changes) {

      editRow = undefined;

    },

    onDblClickRow: function (rowIndex, rowData) {

      if (editRow != undefined) {

        $("#Student_Table").datagrid('endEdit', editRow);

      }

      if (editRow == undefined) {

        $("#Student_Table").datagrid('beginEdit', rowIndex);

        editRow = rowIndex;

      }

    },

    onClickRow: function (rowIndex, rowData) {

      if (editRow != undefined) {

        $("#Student_Table").datagrid('endEdit', editRow);

      } 

    }

  });

} 

效果圖:

 

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • jQuery簡單操作cookie的插件實(shí)例

    jQuery簡單操作cookie的插件實(shí)例

    這篇文章主要介紹了jQuery簡單操作cookie的插件,以實(shí)例形式分析了jQuery操作cookie的插件功能定義與使用技巧,需要的朋友可以參考下
    2016-01-01
  • 整理8個(gè)很棒的 jQuery 倒計(jì)時(shí)插件和教程

    整理8個(gè)很棒的 jQuery 倒計(jì)時(shí)插件和教程

    jQuery 是最流行也是使用最廣泛的 JavaScript 框架,它簡化了 HTML 文檔操作,事件處理,動(dòng)畫效果和 Ajax 交互。下面向大家分享8個(gè)優(yōu)秀的 jQuery 倒計(jì)時(shí)插件和教程
    2011-12-12
  • jQuery.cookie.js使用方法及相關(guān)參數(shù)解釋

    jQuery.cookie.js使用方法及相關(guān)參數(shù)解釋

    一個(gè)輕量級的cookie 插件,可以讀取、寫入、刪除 cookie。這篇文章主要介紹了jQuery.cookie.js使用方法及相關(guān)參數(shù)解釋,需要的朋友可以參考下
    2017-03-03
  • 使用EVAL處理jqchart jquery 折線圖返回?cái)?shù)據(jù)無效的解決辦法

    使用EVAL處理jqchart jquery 折線圖返回?cái)?shù)據(jù)無效的解決辦法

    eval函數(shù)可以把一些處理過程序代碼進(jìn)行解析從而達(dá)到可以執(zhí)行的一個(gè)狀態(tài),本篇文章給大家介紹使用eval處理jqchart jquery折線圖返回?cái)?shù)據(jù)無效的解決辦法,對jqchart jquery相關(guān)內(nèi)容感興趣的朋友一起學(xué)習(xí)吧
    2015-11-11
  • jQuery彈出層插件Lightbox_me使用指南

    jQuery彈出層插件Lightbox_me使用指南

    在使用discuzx中有一個(gè)Message以及Dialog方法來顯示信息對話框。今天寫項(xiàng)目的時(shí)候,需要一個(gè)信息對話框,所以就著手利用lightbox_me插件來寫一個(gè)做備用。
    2015-04-04
  • jquery控制左右箭頭滾動(dòng)圖片列表的實(shí)例

    jquery控制左右箭頭滾動(dòng)圖片列表的實(shí)例

    jquery控制左右箭頭滾動(dòng)圖片列表的實(shí)例,需要的朋友可以參考一下
    2013-05-05
  • jQuery中Ajax的load方法詳解

    jQuery中Ajax的load方法詳解

    本文重點(diǎn)個(gè)大家講解了幾個(gè)jQuery中ajax的load()方法的使用實(shí)例,load()方法是jQuery中最為簡單和常用的Ajax方法,能遠(yuǎn)程載入HTML代碼并插入DOM中
    2015-01-01
  • jquery $.each()使用探討

    jquery $.each()使用探討

    想必大家對jquery $.each()并不陌生吧,使用它可以進(jìn)行元素的遍歷,下面有個(gè)不錯(cuò)的示例,感興趣的朋友可以參考下
    2013-09-09
  • jQuery Div中加載其他頁面的實(shí)現(xiàn)代碼

    jQuery Div中加載其他頁面的實(shí)現(xiàn)代碼

    在做一個(gè)表單簽核系統(tǒng)時(shí),需在要簽核頁面中將表單內(nèi)容(事先做好的PHP頁面)顯示出來,于就是想能不能利用Ajax技術(shù)把這個(gè)事先做好的頁面嵌入到簽核頁面中呢?
    2009-02-02
  • jQuery 1.5 源碼解讀 面向中高階JSER

    jQuery 1.5 源碼解讀 面向中高階JSER

    jQuery 1.5 源碼有8068行。很多想讀 jQuery 源碼的童鞋在讀了一半不到就不敢往下讀了,jQuery是一個(gè) 封裝良好、代碼緊湊 的框架。
    2011-04-04

最新評論