Paging doesn't work with xml data binding

4 posts, 1 answers
  1. Ravi
    Ravi avatar
    3 posts
    Member since:
    Oct 2013

    Posted 08 Oct 2013 Link to this post


    I  am working on a prototype for our new project, after the approval of this prototype we will move ahead and buy the license.

    I want to load the grid with data from xml file, display it with all features (sorting, paging, filtering, etc.)

    Below is the code I use in Controller and Razor

            public ActionResult Index()
                return View(GetQueueItems());

            private static IEnumerable<TmpQueueModel> GetQueueItems()
                IList<TmpQueueModel> ieTmpQueueModel = null;
                TmpQueueModel tmpQueueModel = null;
                    DataSet dsQueue = new DataSet();

                    if (dsQueue.Tables[0].Rows.Count > 0)
                        ieTmpQueueModel = new List<TmpQueueModel>();
                        foreach (DataRow dr in dsQueue.Tables[0].Rows)
                            tmpQueueModel = new TmpQueueModel();
                            tmpQueueModel.Action = dr["Action"].ToString();
                            //tmpQueueModel.AssignedDate = dr["AssignedDate"].ToString();
                            //tmpQueueModel.AssignedTo = dr["AssignedTo"].ToString();
                           // tmpQueueModel.Comment = dr["Comment"].ToString();
                            tmpQueueModel.ConsumerFirstName = dr["ConsumerFirstName"].ToString();
                            tmpQueueModel.ConsumerId = dr["ConsumerId"].ToString();
                            tmpQueueModel.ConsumerLastName = dr["ConsumerLastName"].ToString();
                            tmpQueueModel.ExternalReferenceID = dr["ExternalReferenceID"].ToString();
                            tmpQueueModel.First_Name = dr["First_Name"].ToString();
                            //tmpQueueModel.IsReserved = (bool)dr["IsReserved"];
                            tmpQueueModel.Last_Modified_Date_and_Time = dr["Last_Modified_Date_and_Time"].ToString();
                            tmpQueueModel.Last_Name = dr["Last_Name"].ToString();
                            tmpQueueModel.LastModifiedBy = dr["LastModifiedBy"].ToString();
                            tmpQueueModel.Medicaid_No_ = dr["Medicaid_No_"].ToString();
                            tmpQueueModel.No_ = dr["No_"].ToString();
                            tmpQueueModel.PacketReceivedDate = dr["PacketReceivedDate"].ToString();
                            //tmpQueueModel.QueueHistoryDate = Convert.ToDateTime(dr["QueueHistoryDate"]);
                            tmpQueueModel.QueueId = Convert.ToInt32( dr["QueueId"]);
                            //tmpQueueModel.QueueStatus = dr["QueueStatusId"].ToString();
                    return ieTmpQueueModel;
                    return null;

            public ActionResult QueueItems_Read([DataSourceRequest] DataSourceRequest request)
                return Json(GetQueueItems().ToDataSourceResult(request));

    @model IEnumerable<GenericQueue.Models.TmpQueueModel>

        .Columns(columns =>
            columns.Bound(p => p.ConsumerId).Groupable(false);      
            columns.Bound(p => p.PacketReceivedDate);
            columns.Bound(p => p.First_Name );
            columns.Bound(p => p.Last_Name);        
        .DataSource(dataSource => dataSource
            .Read(read => read.Action("QueueItems_Read", "Grid"))    

    Thanks in advance.

  2. Daniel
    Daniel avatar
    2214 posts

    Posted 10 Oct 2013 Link to this post

    Hello Ravi,

    The code for the Grid and the action methods looks correct. Is the data successfully read from the XML file and  are there any exceptions or JavaScript errors thrown when trying to page? From the code that you provided it seems that the path that you have provided to the ReadXml method is not absolute  so the file is probably not found. If that is the case then you could use code similar to the one in the snippet below to find the correct path:

    var path = Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), "Queue.xml");
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Ravi
    Ravi avatar
    3 posts
    Member since:
    Oct 2013

    Posted 10 Oct 2013 Link to this post

    The data is displayed initially but paging does not work.
  4. Answer
    Ravi avatar
    3 posts
    Member since:
    Oct 2013

    Posted 10 Oct 2013 Link to this post

    I just had to change code in Razor

    Read(read => read.Action("QueueItems_Read", "Grid")
    Read(read => read.Action("QueueItems_Read", "home")
    and it worked.
Back to Top