Lets say I have set up things like this:
narudzbe.aspx.cs
[WebMethod]
public static string getAllPartnere(int kid)
{
string json = string.Empty;
List<stp_WEB_MP_PARTNERI_GetPartneriDDList_Result> partnerList = new List<stp_WEB_MP_PARTNERI_GetPartneriDDList_Result>();
partnerList = DANarudzbe.GetPartnerList(kid);
json = JsonConvert.SerializeObject(partnerList, new Newtonsoft.Json.Converters.StringEnumConverter());
return json;
}
narudzbe.aspx - javascript
$.ajax({
type: "POST",
url: "/Narudzbe/narudzbe.aspx/getAllPartnere",
data: '{kid:"' + Partner_ID + '"}',
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (msg) {
$('#partneri').DataTable({
data: msg.d,
columns: [
{ title: "PartnerID" },
{ title: "Naziv" }
]
});
}
});
narudzbe.aspx - html
...
<table class="display dataTable" id="partneri"></table>
...
I need to know how to use json.net to serialize generic list so that all values are enclosed in quotation marks so that returned list is serialized so that data tables are able to read it.
Serialized list does not have numerical values in quotation marks when serialized like I did so datatables gets some of " quotation marks recognized as values.
I also need to state that this is the first time that I'm using datatables and am not a developer so take it easy on me.
Well to be honest I want to know also if this is the correct way to use in datatables with ajax and server processing or is there easier and more simplistic way.