我正在尝试创建数据表,但我没有成功。请有人帮助我。
这是我的存储过程:
CREATE PROCEDURE [dbo].[pr_SearchMember]
@FilterTerm nvarchar(250) = NULL --parameter to search all columns by
, @SortIndex INT = 1 -- a one based index to indicate which column to order by
, @SortDirection CHAR(4) = 'ASC' --the direction to sort in, either ASC or DESC
, @StartRowNum INT = 1 --the first row to return
, @EndRowNum INT = 10 --the last row to return
, @TotalRowsCount INT OUTPUT
, @FilteredRowsCount INT OUTPUT
AS
BEGIN
--Wrap filter term with % to search for values that contain @FilterTerm
SET @FilterTerm = '%' + @FilterTerm + '%'
DECLARE @Person TABLE
(
CivilID NVARCHAR(12),
FirstName NVARCHAR(50)
, LastName NVARCHAR(50)
, Mobile NVARCHAR(20)
, ParentID NVARCHAR(12)
, RowNum INT
)
INSERT INTO @Person(CivilID
, FirstName
, LastName
, Mobile
, ParentID
, RowNum)
SELECT CivilID
, FirstName
, LastName
, Mobile
, ParentID
, Row_Number() OVER (
ORDER BY
/*VARCHAR, NVARCHAR, CHAR ORDER BY*/
CASE @SortDirection
WHEN 'ASC' THEN
CASE @SortIndex
WHEN 1 THEN CivilID
WHEN 2 THEN FirstName
WHEN 3 THEN LastName
WHEN 4 THEN Mobile
WHEN 5 THEN ParentID
END
END ASC,
CASE @SortDirection
WHEN 'DESC' THEN
CASE @SortIndex
WHEN 1 THEN CivilID
WHEN 2 THEN FirstName
WHEN 3 THEN LastName
WHEN 4 THEN Mobile
WHEN 5 THEN ParentID
END
END DESC
) AS RowNum
FROM dbo.Hierarchy
WHERE @FilterTerm IS NULL
OR CivilID LIKE @FilterTerm
OR FirstName LIKE @FilterTerm
OR LastName LIKE @FilterTerm
OR Mobile LIKE @FilterTerm
OR ParentID LIKE @FilterTerm
SELECT CivilID
, FirstName
, LastName
, Mobile
, ParentID
, RowNum
FROM @Person
WHERE RowNum BETWEEN @StartRowNum AND @EndRowNum
SELECT @TotalRowsCount = COUNT(*)
FROM dbo.Hierarchy
SELECT @FilteredRowsCount = COUNT(*)
FROM @Person
END
这是我的网络服务
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public static string getData()
{
string connString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
List<paluwagan> lstPaluwagans = new List<paluwagan>();
int TotalRowsCount = 0, FilteredRowsCount = 0;
string data = "", sSearch = HttpContext.Current.Request.Params["sSearch"], sSortDir_0 = HttpContext.Current.Request.Params["sSortDir_0"];
int? iSortCol_0 = ToInt(HttpContext.Current.Request.Params["iSortCol_0"]);
int? iDisplayStart = ToInt(HttpContext.Current.Request.Params["iDisplayStart"]);
int? iDisplayLength = ToInt(HttpContext.Current.Request.Params["iDisplayLength"]);
int? sEcho = ToInt(HttpContext.Current.Request.Params["sEcho"]); ;
using (SqlConnection cn = new SqlConnection(connString))
{
using (SqlCommand cmd = new SqlCommand("pr_SearchMember", cn))
{
try
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@FilterTerm", sSearch);
cmd.Parameters.AddWithValue("@SortIndex", iSortCol_0);
cmd.Parameters.AddWithValue("@SortDirection", sSortDir_0);
cmd.Parameters.AddWithValue("@StartRowNum", iDisplayStart);
cmd.Parameters.AddWithValue("@EndRowNum", iDisplayStart + iDisplayLength);
cmd.Parameters.Add("@TotalRowsCount", SqlDbType.Int);
cmd.Parameters["@TotalRowsCount"].Direction = ParameterDirection.Output;
cmd.Parameters.Add("@FilteredRowsCount", SqlDbType.Int);
cmd.Parameters["@FilteredRowsCount"].Direction = ParameterDirection.Output;
cn.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
if (dr.HasRows)
{
while (dr.Read())
{
paluwagan lstPaluwagan = new paluwagan();
lstPaluwagan.civilID = dr["CivilID"].ToString();
lstPaluwagan.firstName = dr["FirstName"].ToString();
lstPaluwagan.lastName = dr["LastName"].ToString();
lstPaluwagan.mobile = dr["Mobile"].ToString();
lstPaluwagan.parentID = dr["ParentID"].ToString();
lstPaluwagan.rowNum = int.Parse(dr["RowNum"].ToString());
lstPaluwagans.Add(lstPaluwagan);
}
dr.Close();
TotalRowsCount = Convert.ToInt32(cmd.Parameters["@TotalRowsCount"].Value.ToString());
FilteredRowsCount = Convert.ToInt32(cmd.Parameters["@FilteredRowsCount"].Value.ToString());
}
}
JavaScriptSerializer serializer = new JavaScriptSerializer();
data += "{\"sEcho\":\"" + sEcho + "\",";
data += "\"aaData\":" + serializer.Serialize(lstPaluwagans) + ",";
data += "\"iTotalRecords\":\"" + TotalRowsCount.ToString() + "\",";
data += "\"iTotalDisplayRecords\":\"" + FilteredRowsCount.ToString() + "\"";
data += "}";
}
catch (Exception ex)
{
throw ex.InnerException ;
}
if (cn.State == System.Data.ConnectionState.Open) cn.Close();
return data;
}
}
}
这是我的javascript代码
<script type="text/javascript">
$(document).ready(function () {
$("#org").jOrgChart({
chartElement: '#chart',
dragAndDrop: false
});
$('#members').dataTable({
"bServerSide": true,
"sAjaxSource": "CivilID.aspx/getData",
"sAjaxDataProp": "",
"bProcessing": true,
"bDestroy": true,
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "GET",
"url": sSource,
"data": aoData,
"success": function (msg) {
var json = jQuery.parseJSON(msg.d);
fnCallback(json);
//$("#members").show();
}
});
},
"aoColumns": [
{ "sName": "civilID" },
{ "sName": "firstName" },
{ "sName": "lastName" },
{ "sName": "mobile" },
{ "sName": "parentID" },
{ "sName": "rowNum" }
]
});
});
</script>
我不知道,但我总是得到TypeError。请注意,我没有任何jSON错误
BElow是我的json数据
{"sEcho":"1","aaData":[{"civilID":"123456789012","firstName":"Adel","lastName":"Alshammeri","mobile":"99466444","parentID":"","rowNum":1},{"civilID":"267122700454","firstName":"Adel","lastName":"S","mobile":"99466444","parentID":"","rowNum":2},{"civilID":"275030107784","firstName":"Mahfuz","lastName":"S","mobile":"66390129","parentID":"267122700454","rowNum":3},{"civilID":"265103002897","firstName":"Antonio","lastName":"S","mobile":"99073592","parentID":"267122700454","rowNum":4},{"civilID":"272110203967","firstName":"Reco","lastName":"S","mobile":"50956026","parentID":"267122700454","rowNum":5},{"civilID":"259061403367","firstName":"Eliseo","lastName":"S","mobile":"50956026","parentID":"275030107784","rowNum":6},{"civilID":"265020307919","firstName":"Liza","lastName":"S","mobile":"66642749","parentID":"275030107784","rowNum":7},{"civilID":"244101000772","firstName":"AlAsmar","lastName":"S","mobile":"99089648","parentID":"275030107784","rowNum":8},{"civilID":"273100700825","firstName":"Alhadad","lastName":"S","mobile":"60993977","parentID":"265103002897","rowNum":9},{"civilID":"268082304389","firstName":"AILEEN","lastName":"s","mobile":"66481975","parentID":"265103002897","rowNum":10}],"iTotalRecords":"42","iTotalDisplayRecords":"42"}
答案 0 :(得分:0)
它可以在aoColumns中将sName更改为mData,使用aoData更改sAjaxDataProp
答案 1 :(得分:-1)
在jOrgChart插件中,您需要构建一个表示节点嵌套的嵌套无序列表。显示在以下链接中。
https://github.com/wesnolte/jOrgChart
问题可能在于嵌套的无序列表结构。使用jOrgChart的开发者版本,然后你就可以找到确切的问题。