<script type="text/javascript">
$(document).ready(function () {
$("#grid").kendoGrid({
height: 360, groupable: true, scrollable: true, sortable: true, pageable: true,
columns: [{field: "name",title: "Name"},{field: "number",title: "Number"},{field: "type",title: "Type"},
{field: "low",title: "Low"},{field: "high",title: "High"},{field: "status",title: "Status"}],
dataSource: {
transport: {
read: {
// the remote service url
url: "/DomainService/KendoDomainService.svc/json/GetSpt_values",
// JSONP is required for cross-domain AJAX
dataType: "jsonp"}}},
schema: {
// the data which the data source will be bound to is in the "results" field
//data: "GetSpt_valuesResult"
}});});
</script>
When i run above URL in my browser, i get data from json. So, i have data and i have the kendo grid. The data i am fetching from the MasterDB (SQL SERVER) SPT_VALUES table.
the data snippet is as follow:
{"GetSpt_valuesResult":{"TotalCount":2506,"RootResults":
[{"high":null,"low":null,"name":"rpc","number":1,"status":0,"type":"A "},
{"high":null,"low":null,"name":"pub","number":2,"status":0,"type":"A "},
{"high":null,"low":null,"name":"sub","number":4,"status":0,"type":"A "},
{"high":null,"low":null,"name":"dist","number":8,"status":0,"type":"A "}]}}
Could you please help my in binding data as i am really new to the jquery.
Kind Regards,
waseem
{"d":["20417","20418","20419","20420","20421","20422","20424","20425","20426","20427","20443","20480","20489","20491","20492","20495","20497","20498"]}
[ServiceContract(Namespace = "QS")][AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]public class PSService{ [OperationContract()] [WebGet(BodyStyle = WebMessageBodyStyle.WrappedRequest)] public string[] GetJobs() { try { StringBuilder sb = new StringBuilder(); sb.Append("select ID from ff_job"); string sql = sb.ToString(); DataTable dt = Database.Instance.ExecuteQueryToDataTable(sql); List<string> IJobList = new List<string>(); string sJobID; foreach (DataRow dr in dt.Rows) { sJobID = dr["ID"].ToString(); IJobList.Add(sJobID); } return IJobList.ToArray();
} catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); return null; } }
<div id="grid">
</div>
<script type="text/javascript"> $(document).ready(function () { $("#grid").kendoGrid({ dataSource: { type: "odata", transport: { read: "http://localhost:3444/BootStrap/PSService.svc/getjobs" }, pageSize: 10 }, schema: { model: { fields: { ID: { type: "number" } } } }, height: 360, groupable: true, scrollable: true, sortable: true, pageable: true, columns: [{ field: "ID", width: 90, title: "Job No." }] }); }); </script>$("#grid").kendoGrid({ dataSource: dataSource, navigatable: true, pageable: true, sortable: true, height: 400, filterable: false, toolbar: [ { name: "create", text: "<?php echo $this->translate("Add Account"); ?>" } ], columns: [ { field: "Company", width: "120px", title: "<?php echo $this->translate("Company"); ?>" }, { field: "Name", width: "120px", title: "<?php echo $this->translate("Name"); ?>" }, { field: "Email", width: "200px", title: "<?php echo $this->translate("Email"); ?>" }, { field: "AccountID", width: "150px", title: "<?php echo $this->translate("Account ID"); ?>" }, { field: "Active", width: "60px", title: "<?php echo $this->translate("Active"); ?>" }, { field: "Date", width: "110px", title: "<?php echo $this->translate("Expired"); ?>", template: '#= kendo.toString(Date,"dd.MM.yyyy") #' }, { command: [ {name: "edit"}, {name: "destroy"} ] }, { field: "PassButton", width: "60px", title: "<?php echo $this->translate("Send"); ?>", template: "<input type='button' class='k-button k-button-send' value='' onclick='myFunction(\"#=AccountID#\")'/>" } ], editable: "inline" });