You are welcome to repost it. Please indicate the source for reprinting! I hope this note will be useful to myself and everyone, but I have a limited level. If something goes wrong, I hope you can point out more criticism. Thank you! Today is the prompt, format table, and table button of the DataGrid frame:
The DataGrid is still used today, because there are too many attribute methods and it cannot be completed. Let's take a look at the examples and demos on the official website: examples on the official website
Column StyleCode:
Styler:Function(Value, rowdata, index ){//Set the column style (column attribute API), value column value, index column index, and rowdata row dataIf(Index <3){Return'Background-color: # ffee00; color: red ;';}}
Line style code:
Rowstyler:Function(Index, row ){//Same as Column Style usageIf(Row. Code = 001){Return'Background-color: # 6293bb; color: # FFF ;';}}
Formatter method usage:
Formatter: Function (Value, rowdata, index ){ // Value: the value of a field. Rowdata: Row data. Rowindex: Row index. Return "<Span Title = '" + value + "'>" + value + "<span> "; // Prompt when you move your mouse over a cell // Return "*****"; // display the asterisks } Formatter: Function (Value, rowdata, index ){ // Value: the value of a field. Rowdata: Row data. Rowindex: Row index. Return "<Button onclick = 'clickfunc (" + index + "); '> operation </button> "; // Pass the index to the method. You can select this row. } // Operation clicking Method Function Clickfunc (INDEX ){ VaR Rows = $ ("# DG"). DataGrid ("getrows" ); Alert (rows [Index]. ADDR ); // Obtain the data of the click row. }
Example:
Source code: Download source code