Custom Input Function of jqgrid-colmodel custom edittype control type

Source: Internet
Author: User

References:Http://www.trirand.com/jqgridwiki/doku.php? Id = wiki: common_rules # editable

There are some problems with the edittype: 'custom' example in the document. For correct call, see the following example.

In this example, we mainly want to implement the onclick event in the input box.

 Colnames: ['id', 'username', 'Password', 'authorization'],
 Colmodel :[
  {Name: 'id', index: 'id', width: 60, key: True, Editable: false,
   Searchoptions: {SOPT: ['eq ', 'ne', 'lt ', 'le', 'gt', 'ge ']},
  {Name: 'username', index: 'username', width: 120, sortable: false, Editable: True,
   Editrules: {required: true }},
  {Name: 'Password', index: 'Password', width: 120, sortable: false, Editable: True,
   Edittype: 'custom', editoptions: {custom_element: myelem, custom_value: myvalue }},
  {Name: 'usertype', index: 'usertype', width: 60, Editable: True,
   Searchoptions: {SOPT: ['eq ', 'ne', 'lt ', 'le', 'gt', 'ge']}
 ],

The JS Code is as follows:

 Function myelem (value, options ){
 VaR El = Document. createelement_x ("input ");
 El. type = "password ";
 El. value = value;
 El. onclick = function () {El. Focus (); El. Select ();};
 // Alert ("myelem:" + value );
 Return El;
 };
 
 Function myvalue (ELEM, operation, value ){
 // Alert ("myvalue:" + value );
 If (Operation = 'get '){
  Return $ (ELEM). Val ();
 } Else if (Operation === 'set '){
  $ (ELEM). Val (value );
  }
 };

Note: myelemAndThe myvalue method must be placed before the grid creation. If it cannot be found

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.