Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use easyuidatagrid to receive and transmit parameters

Shulou Source: shulou.com Published: 2022-06-03 12:49:20 10月02日 Update

How to use easyui datagrid to receive and transmit parameters, in view of this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Rows is the number of rows passed from the client, and page is the page number. You only need two parameters to pass parameters. In the sql statement, _ row and _ page are local variables declared by themselves, and the values are still the corresponding row and page, just for calculation.

Use the database class to get its DataTable, convert it to json format and transfer it to the client through a general processor, and the client will display ok. Here I use easyui datagrid to receive and transmit parameters. This is a general way of thinking.

String sql = "select top" + rows + "* from TestData where testID not in (select top" + (_ rows * (_ page-1)) + "testID from TestData order by testID desc) order by testID desc"

/ / DataTable is converted into json. The total number of data passed to the client is "total". Without this, the client will not show the total number of data. Public static string CreateJsonParameters (DataTable dt, bool displayCount, int totalcount) {StringBuilder JsonString = new StringBuilder (); / / Exception Handling if (dt! = null) {JsonString.Append ("{"); if (displayCount) {JsonString.Append ("\" total\ ":"); JsonString.Append (totalcount); JsonString.Append (",") } JsonString.Append ("\" rows\ ": ["); for (int I = 0; I < dt.Rows.Count; iTunes +) {JsonString.Append ("{"); for (int j = 0; j < dt.Columns.Count) If +) {if (j < dt.Columns.Count-1) {/ / if (dt.Rows [I] [j] = = DBNull.Value) continue If (dt.Columns.dataType = = typeof (bool)) {JsonString.Append ("\"+ dt.ColumnName [j] .ColumnName +": "+ dt.Rows [I] [j] .ToString () .ToString () +", ") } else if (dt.Columns [j] .dataType = = typeof (string)) {JsonString.Append ("\"+ dt.ColumnName [j] .ColumnName +": "+"\ "" + dt.Rows [I] [j] .ToString (). Replace ("\", "\") + "\", ") } else {JsonString.Append ("\"+ dt.ColumnName [j] .ColumnName +": "+"\ "" + dt.Rows [I] [j] + "\", ") }} else if (j = = dt.Columns.Count-1) {/ / if (dt.Rows [I] [j] = = DBNull.Value) continue If (dt.Columns [j] .dataType = = typeof (bool)) {JsonString.Append ("\"+ dt.ColumnName [j] .ColumnName +": "+ dt.Rows [I] [j] .ToString ()) } else if (dt.Columns [j] .dataType = = typeof (string)) {JsonString.Append ("\"+ dt.ColumnName [j] .ColumnName +": "+"\ "" + dt.Rows [I] [j] .ToString (). Replace ("\", "\") + "\") } else {JsonString.Append ("\"+ dt.ColumnName [j] .ColumnName +": "+"\ "" + dt.Rows [I] [j] + "\") } / * end Of String*/ if (I = = dt.Rows.Count-1) {JsonString.Append ("}");} else {JsonString.Append ("},");}} JsonString.Append ("]") JsonString.Append ("}"); return JsonString.ToString (). Replace ("\ n", ");} else {return null }} this is the answer to the question about how to use easyui datagrid to receive and transmit parameters. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Tags: Customers clients data questions more help answers easy easy two content parameters variables guys partners local ideas total database methods Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information Shulou Technology MySQL Xiaomi