機能するには合計とステータスが必要なようです。C# を使用して、これを多かれ少なかれ自動的に処理するクラスを作成します。
// a few using statements that are needed
using NewtonSoft.Json;
using System.Data;
using System.Data.SqlClient;
// the class we will need to Serialize
public class w2return
{
public string status = "success";
public int total = 0;
public DataTable records;
}
Web サービス関数で、次のようにします。
w2return x = new w2return();
// write some code to return a DataTable
x.records = SomeCodeThatReturnsDataTable();
x.total = x.records.Rows.count();
return JsonConvert.SerializeObject(x); // this assumes your function returns a string
シリアル化プロセスはすべてを「d」というメンバー変数にラップするため、w2ui の「parse」コールバックを使用してクライアント側で解析する必要があります (jQuery を使用していると仮定します)。
parser: function (responseText) { return $.parseJSON($.parseJSON(responseText).d); }
これが誰かに役立つことを願っています。