Home  >  Article  >  Web Front-end  >  Several ways to customize button buttons in Jquery_jquery

Several ways to customize button buttons in Jquery_jquery

WBOY
WBOYOriginal
2016-05-16 16:44:582524browse

1. The first method is relatively simple

Copy the code The code is as follows:

"columns": [

{ "data": null,defaultContent: '', orderable: false },

],

You can understand what it means from the literal meaning of the code, but I don’t know how to get the line change information from it, so it doesn’t seem very practical. It’s OK to define a default value.
Copy code The code is as follows:

{ "data": "id",orderable: false ,
"mRender":function(data,type,full){
return "";
}
},

I just saw a way to use callbacks. You can also get the value of the column and pass it on, but you can only get one value. It is still not as good as the second method.

2. The second one is a little more troublesome, but more practical
Copy the code The code is as follows:

"fnRowCallback":function(nRow,aData,iDataIndex){
var id = $('td', nRow).eq(0).text();
var ip = $( 'td', nRow).eq(3).text();
$('td:eq(-1)',nRow).html('Modify '
'Delete');
return nRow;
},

Call a callback method when initializing row data. You can easily obtain the row data and complete the submission function. However, there is a disadvantage. It requires background json transmission. An empty field is not flexible enough.

3. The third method is to combine the two methods, which can completely eliminate the need for background operations
Copy code The code is as follows:

{ "data": null,orderable: false,}

Copy code The code is as follows:

"fnRowCallback":function(nRow,aData,iDataIndex){
var id = $('td', nRow).eq (0).text();
var ip = $('td', nRow).eq(3).text();
$('td:eq(-1)',nRow). html('Modify '
'delete');
return nRow;
},
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn