Easyui DataGrid Edit Cell

Source: Internet
Author: User

Previous article Easyui DataGrid editable cells implement editable cells, if more than one column needs to be editable when clicking on a cell, the entire row will be edited

Such as:

Now click a cell to make the cell editable only

<TABLE>Tag Add Onclickcell
<table id="dg" class="easyui-datagrid" data-options="onClickCell: onClickCell">


Add editor on columns that need to be edited
<th data-options="field:‘itemId‘,editor:‘numberbox‘"></th>

You can also specify

    • Number of decimal digits: editor:{type: ' Numberbox ', Options:{precision:1}}

    • Text type: Editor: ' Text '

    • Checkbox:editor:{type: ' checkbox ', Options:{on: ' Start ', off: ' Off '}}

The effect is as follows:


Core code
<script type="Text/javascript">$.extend ($.fn.datagrid.methods, {editcell: function(JQ, param) {        returnJq.each ( function() {            varOPTs = $ ( This). DataGrid (' Options ');varFields = $ ( This). DataGrid (' Getcolumnfields ',true). Concat ($ ( This). DataGrid (' Getcolumnfields ')); for(vari =0; i < fields.length; i++) {varCol = $ ( This). DataGrid (' Getcolumnoption ', Fields[i]); Col.editor1 = Col.editor;if(Fields[i]! = Param.field) {Col.editor =NULL; }            }            $( This). DataGrid (' BeginEdit ', Param.index); for(vari =0; i < fields.length; i++) {varCol = $ ( This). DataGrid (' Getcolumnoption ', Fields[i]);            Col.editor = Col.editor1;    }        }); }});varEditindex =undefined;//End Edit function endediting() {    if(Editindex = =undefined) {return true}if($(' #dg '). DataGrid (' Validaterow ', Editindex)) {$ (' #dg '). DataGrid (' EndEdit ', Editindex); Editindex =undefined;return true; }Else{return false; }}//Click cell function onclickcell(Index, field) {    if(Endediting ()) {        $(' #dg '). DataGrid (' SelectRow ', index). DataGrid (' Editcell ', {index:index, field:field});    Editindex = index; }}</script>
Online Demo

Itmyhome

Easyui DataGrid Edit Cell

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.