Jquery several ways to customize button buttons

  • 2020-03-30 03:18:59
  • OfStack

1. The first method is relatively simple
 
"columns": [ 

{ "data": null,defaultContent: '<input type="button" onclick="" value=" Ha ha " />', orderable: false }, 

], 

You can tell what the code means by its literal meaning, but I don't know how to get the line change information from it, so it's not very practical, and it's ok to define default values.
 
{ "data": "id",orderable: false, 
"mRender":function(data,type,full){ 
return "<input type='button' onclick='' value='"+data+"'/>"; 
} 
}, 

I just saw that one way is to use a callback, and you can also get the value of the column and pass it, but you can only get one value, and it's still not as good as the second way.

2. The second one is a bit cumbersome, but more practical
 
"fnRowCallback":function(nRow,aData,iDataIndex){ 
var id = $('td', nRow).eq(0).text(); 
var ip = $('td', nRow).eq(3).text(); 
$('td:eq(-1)',nRow).html('<a href="javascript:onUpdate(''+id+'',''+ip+'')"> Modify the </a> '+ 
'<a href="javascript:onDel('+iDataIndex+')"> delete </a>'); 
return nRow; 
}, 

Calling a callback method when initializing the row data can easily obtain the row data and complete the submission function, but there is a disadvantage that requires the background json to pass an empty field, which is not flexible enough.

3, the third method, is the combination of the two methods, can be completely foreground without background operation
 
{ "data": null,orderable: false,} 

The same code at the page code block index 2

Related articles: