Hi,
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
----------XXXXXXXXXXX------------
Thanks in advance.
Regards,
Ravi
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;
try
{
DataSet dsQueue = new DataSet();
dsQueue.ReadXml("\\App_Data\\Queue.xml");
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();
ieTmpQueueModel.Add(tmpQueueModel);
}
}
return ieTmpQueueModel;
}
catch
{
return null;
}
}
public ActionResult QueueItems_Read([DataSourceRequest] DataSourceRequest request)
{
return Json(GetQueueItems().ToDataSourceResult(request));
}
----------XXXXXXXXXXX------------
@model IEnumerable<
GenericQueue.Models.TmpQueueModel
>
@(Html.Kendo().Grid(Model)
.Name("Grid")
.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);
})
.Groupable()
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Read(read => read.Action("QueueItems_Read", "Grid"))
)
)
Thanks in advance.
Regards,
Ravi