I created 1 REST WCF service (with responseType xml), & uasing this service i trying to get data at client side (MVC Application), in mvc controller i geting data from service, & i stored this data in XmlElement.
& now i want this data in Telerik Gridview
In View I wrote ajax Post method to get response & store in grid view
but i never understand how to return this xmlelement to ajax method and how to store in Grid View form ajax method
my written code at below..
View
****************************
this is my grid..
@(Html.Telerik().Grid("......").Name("Grid")
.Groupable()
.Filterable()
.Selectable()
.DataKeys(keys => keys.Add("CurrentDateTime"))
)
// here i passing date to get data from service
function GetReport() {
var CDateTime = new Date();
CDateTime = $('#DATE').val();
var getreportStr = new String();
getreportStr = ""+ CDateTime +" ";
AtdReport(getreportStr);
}
//ajax method
function AtdReport(getreportStr){
var data=new String();
data=getreportStr;
$.ajax({
type: 'POST',
url: '@Url.Action("GetRprt")',
data: { data: data },
async: false,
success: function (response) {
var GridView = $('#Grid').data('t-Grid');
var jsonobj;
var obj = JSON.parse(response);
GridView.bindTo(obj);
Window.location.reload(true);
},
error: function (xhr, ajaxOptions, thrownError) {
window.location.reload(true);
}
});
}
Here i trying to return the data at ajax post
Controller
****************************
[HttpPost]
[ValidateInput(false)]
public string GetRprt(string data)
{
HttpClient htp = new HttpClient("http://localhost:50361/MoAttndReport/date");
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(htp.MakeRequest("POST", data).ResponseBody);
XmlElement xe = (XmlElement)xDoc.DocumentElement;
return xe.GetElementsByTagName("AtdReport")[0].InnerText;
}
please give some suggestions....
Thanks,

Dinkar ChavhanPosted Jul 20, 2012, 12:40 AM
$.ajax({
url: "/Portfolios/PortfolioList",
type: "POST",
async: true,
success: function(data){
if (!data)
alert("No xml data returned.");
else{
var $xml = $(data);
var $title = $xml.find("portfolioSummary").text();
$('.xmlTest').text("Wow are we getting somewhere ?!!!");
$('.xmlTest').append($xml.text());
alert("success!");
}
},
error: function (error) {
alert("failed");
}
});
And Used Grid