jQWidgets Forums

Forum Replies Created

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts

  • thommy
    Member

    Peter,

    Thanks for the response and it’s working. However you haven’t responded to my second question:
    2. How can I reflect the real time data from a data source on the grid without refreshing the grid window. Is it possible to use a timer, say at the interval of 5 milliseconds to fetch the updates and show on the grid instantly? If yes, please show me the sample code for it.

    Regards


    thommy
    Member

    Hi Peter,

    Thanks for your untiring support I however managed to fix the problem. It wasn’t related to JSON format but for some reason ASP.NET MVC was not loading the returned JSON data from the server fo a reason I dont know. So instead of the writing the javascript code that fetches data from a controller separately in another file and attach it to the view using tags, I just added the code to the cshtml page just after the header between …here… tags. And boom! it worked!!

    Thanks!


    thommy
    Member

    Hi Peter,

    I have tried it’s working but when I try to retrieve the data from the server of my application, it’s giving no errors. If I use the function JSON.stringify(sample data), the grid is not populating still even when the json string is correctly formatted.


    thommy
    Member

    It is the exact data returned from the server. If I parse it directly to the jqxGrid it’s saying no data to display. And when I try to format it ,still the jqxgrid widget is failing to display the data. How do I correctly format it and parse it to JSON?


    thommy
    Member

    Peter,

    I am able to populate the grid without errors if I use the datasource I created manually, but if I use the returned json string from the server directly, the browser is throwing the json.parse unexpected end of data error. Am not sure what I am doing wrongly.


    thommy
    Member

    Thanks Peter for the reply.

    Let me paste the actual data in my code for the comparison.

    Manually created json string variable:

    var datasource ='[{ “DeptName”: “Finance”, “DeptID”: “Fin001”},{“DeptName”: “Human Resources”,”DeptID”: “HR003”},{ “DeptName”: “Infomation Technology”, “DeptID”: “IT002”},{ “DeptName”: “Operations”, “DeptID”: “Opts004”},{ “DeptName”: “Treasury”, “DeptID”: “Trsy-03”}]’;

    Returned JSON string from the server:

    [{“DeptName”: “Finance” ,”DeptID”: “Fin001”},{“DeptName”: “Human Resources” ,”DeptID”: “HR003”},{“DeptName”: “Infomation Technology” ,”DeptID”: “IT002”},{“DeptName”: “Operations” ,”DeptID”: “Opts004”},{“DeptName”: “Treasury” ,”DeptID”: “Trsy-03”}]

    I cant seem to find the error.


    thommy
    Member

    mates,

    I am still failing to retrive any data from my controllers. All I am getting is [object],[object],[object],[object] as results. My code is as below:
    ———————————————————————————————————–
    the code part that sends the request to the controller on the server from the view
    ————————————————————————————————————
    @model IEnumerable

    @{
    ViewBag.Title = “Index”;
    }

    $(document).ready(function(){
    var theme = getDemoTheme();
    var title =’Department Details’;
    var url = ‘/Department/GetDepartments’;

    var rowdata =[];

    $.ajax({
    type: ‘POST’,
    url: url,
    datatype: ‘json’,
    success: function(data){
    //rowdata = data;
    alert(data); //here I am alerting just to see the results
    }
    });

    —————————————————————————————–
    the controller code
    —————————————————————————————–

    [HttpPost]
    public JsonResult GetDepartments()
    {
    var result = db.Departments.ToList();
    var departments = from d in result
    select new {d.DeptID,d.DeptName};
    return Json(departments);
    }

    Where Am I going wrong?


    thommy
    Member

    Thanks Peter,

    I will look into it.


    thommy
    Member

    I am using Mozilla Firefox ver 23.01 and Chrome. How can I know I am referencing the libraries correctly?

Viewing 9 posts - 1 through 9 (of 9 total)