void cboDriver_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) { Facade.IResource facResource = new Facade.Resource(); DataSet ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Driver, false); DataTable dt = ds.Tables[0]; DataTable boundResults = dt.Clone(); int itemsPerRequest = 20; int itemOffset = e.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } for (int i = itemOffset; i < endOffset; i++) { boundResults.ImportRow(dt.Rows[i]); } cboDriver.Items.Clear(); cboDriver.DataSource = boundResults; cboDriver.DataBind(); if (boundResults.Rows.Count > 0) { e.Message = string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dt.Rows.Count.ToString()); } }
void cboResource_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) { cboResource.Items.Clear(); Facade.IResource facResource = new Facade.Resource(); DataSet ds = facResource.GetAllResourcesFiltered(e.Text, false, true); int itemsPerRequest = 20; int itemOffset = e.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItem rcItem; for (int i = itemOffset; i < endOffset; i++) { rcItem = new Telerik.Web.UI.RadComboBoxItem(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["ResourceId"].ToString(); cboResource.Items.Add(rcItem); } if (dt.Rows.Count > 0) { e.Message = string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset, dt.Rows.Count); } }
public RadComboBoxItemData[] GetAllTrailers(RadComboBoxContext context) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); string[] clientArgs = context["FilterString"].ToString().Split(':'); int depotID = 0; depotID = int.Parse(clientArgs[0]); Facade.IResource facResource = new Facade.Resource(); DataSet ds = facResource.GetAllResourcesFiltered(context.Text, eResourceType.Trailer, depotID, false, true); int itemsPerRequest = 20; int itemOffset = context.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItemData rcItem = null; for (int i = itemOffset; i < endOffset; i++) { rcItem = new Telerik.Web.UI.RadComboBoxItemData(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["ResourceId"].ToString(); result.Add(rcItem); } return(result.ToArray()); }
//--------------------------------------------------------------------------------------- protected void cboVehicle_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) { Page.Response.Cache.SetCacheability(HttpCacheability.NoCache); cboVehicle.Items.Clear(); Telerik.Web.UI.RadComboBoxItem rcItem = new Telerik.Web.UI.RadComboBoxItem(); DataSet ds = null; Facade.IResource facResource = new Facade.Resource(); ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Vehicle, false); if (ds != null) { int endOffset = 0; DataTable boundResults = BindComboBoxItems(ds.Tables[0], e.NumberOfItems, out endOffset); cboVehicle.DataSource = boundResults; cboVehicle.DataBind(); if (boundResults.Rows.Count > 0) { e.Message = string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), boundResults.Rows.Count.ToString()); } } }
public RadComboBoxItemData[] GetAllDrivers(RadComboBoxContext context) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); Facade.IResource facResource = new Facade.Resource(); DataSet ds = facResource.GetAllResourcesFiltered(context.Text, eResourceType.Driver, false); var itemsPerRequest = context.ContainsKey("ItemsPerRequest") ? (int)context["ItemsPerRequest"] : 20; DataTable dt = ds.Tables[0]; var itemCount = dt.Rows.Count; int itemOffset = context.NumberOfItems; int endOffset = itemsPerRequest == 0 ? itemCount : itemOffset + itemsPerRequest; if (endOffset > itemCount) { endOffset = itemCount; } for (int i = itemOffset; i < endOffset; i++) { var rcItem = new Telerik.Web.UI.RadComboBoxItemData(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["ResourceId"].ToString(); result.Add(rcItem); } return(result.ToArray()); }
public RadComboBoxItemData[] GetVehicles(RadComboBoxContext context) { List <RadComboBoxItemData> result = new List <RadComboBoxItemData>(); // If the context contains a "TopItemText" key then add to a the top of the result list an item containing this text (for example "- all -" or "- select -") // But only if the list is currently empty. If they have clicked the ShowMoreResultsBox arrow, we don't want to add another "- all -" bool hasTopItemText = false; var topItemText = context.ContainsKey("TopItemText") ? context["TopItemText"].ToString() : string.Empty; hasTopItemText = !string.IsNullOrWhiteSpace(topItemText); if (hasTopItemText && context.NumberOfItems == 0) { result.Add(new Telerik.Web.UI.RadComboBoxItemData { Text = topItemText }); } string[] clientArgs = context["FilterString"].ToString().Split(':'); int depotID = int.Parse(clientArgs[0]); var query = (context.ContainsKey("Text") && context.Text != topItemText) ? context.Text : string.Empty; Facade.IResource facResource = new Facade.Resource(); DataSet ds = facResource.GetAllResourcesFiltered(query, eResourceType.Vehicle, depotID, false, true); int itemsPerRequest = 20; int itemOffset = context.NumberOfItems; // If the list contains a Top Item (e.g. -All-) and the list is already populated (the ShowMoreResultsBox has been clicked), do not include the Top Item or the offset will skip a vehicle. if (hasTopItemText && context.NumberOfItems > 0) { itemOffset--; } int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItemData rcItem = null; for (int i = itemOffset; i < endOffset; i++) { rcItem = new Telerik.Web.UI.RadComboBoxItemData(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["ResourceId"].ToString(); result.Add(rcItem); } return(result.ToArray()); }
void cboTrailer_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) { ((Telerik.Web.UI.RadComboBox)sender).Items.Clear(); #region Get ControlArea and Traffic Area string[] clientArgs = e.Context["FilterString"].ToString().Split(':'); int controlAreaId = 0; controlAreaId = int.Parse(clientArgs[0]); string[] taids = clientArgs[1].Split(','); int[] trafficAreas = new int[taids.Length]; for (int i = 0; i < taids.Length; i++) { trafficAreas[i] = int.Parse(taids[i]); } #endregion Facade.IResource facResource = new Facade.Resource(); DataSet ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Trailer, controlAreaId, trafficAreas, true); int itemsPerRequest = 20; int itemOffset = e.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItem rcItem = null; for (int i = itemOffset; i < endOffset; i++) { rcItem = new Telerik.Web.UI.RadComboBoxItem(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["ResourceId"].ToString(); ((Telerik.Web.UI.RadComboBox)sender).Items.Add(rcItem); } if (dt.Rows.Count > 0) { e.Message = string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dt.Rows.Count.ToString()); } }
protected void cboDriver_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) { Page.Response.Cache.SetCacheability(HttpCacheability.NoCache); ((Telerik.Web.UI.RadComboBox)sender).Items.Clear(); Facade.IResource facResource = new Facade.Resource(); DataSet ds = null; #region Get ControlArea and Traffic Area // As thgis is only set when there is no call back or post back we need to get the correct values #endregion ds = facResource.GetAllResourcesFiltered("%" + e.Text, eResourceType.Driver, false); int itemsPerRequest = 30; int itemOffset = e.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; Telerik.Web.UI.RadComboBoxItem rcItem = null; for (int i = itemOffset; i < endOffset; i++) { rcItem = new Telerik.Web.UI.RadComboBoxItem(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["ResourceId"].ToString(); ((Telerik.Web.UI.RadComboBox)sender).Items.Add(rcItem); } if (dt.Rows.Count > 0) { e.Message = string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dt.Rows.Count.ToString()); } }
void cboVehicle_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) { ((Telerik.Web.UI.RadComboBox)sender).Items.Clear(); Telerik.Web.UI.RadComboBoxItem rcItem = new Telerik.Web.UI.RadComboBoxItem(); DataSet ds = null; string[] clientArgs = e.Context["FilterString"].ToString().Split(':'); if (e.Context["FilterString"] != null) { if (clientArgs[0] == "true") { // Get the Drivers usual vehicle Facade.IDriver facDriver = new Facade.Resource(); Entities.Driver driver = facDriver.GetDriverForResourceId(int.Parse(clientArgs[1])); Entities.Vehicle vehicle = ((Facade.IVehicle)facDriver).GetForVehicleId(driver.AssignedVehicleId); if (vehicle != null) { rcItem.Text = vehicle.RegNo; rcItem.Value = vehicle.ResourceId.ToString(); rcItem.Selected = true; ((Telerik.Web.UI.RadComboBox)sender).Items.Add(rcItem); } } else { int controlAreaId = 0; int[] trafficAreas = new int[clientArgs.Length - 1]; controlAreaId = int.Parse(clientArgs[0]); for (int i = 1; i < clientArgs.Length; i++) { trafficAreas[i - 1] = int.Parse(clientArgs[i]); } Facade.IResource facResource = new Facade.Resource(); ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Vehicle, controlAreaId, trafficAreas, true); } } else { Facade.IResource facResource = new Facade.Resource(); ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Vehicle, false); } if (ds != null) { int itemsPerRequest = 20; int itemOffset = e.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; for (int i = itemOffset; i < endOffset; i++) { rcItem = new Telerik.Web.UI.RadComboBoxItem(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["ResourceId"].ToString(); ((Telerik.Web.UI.RadComboBox)sender).Items.Add(rcItem); } if (dt.Rows.Count > 0) { e.Message = string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dt.Rows.Count.ToString()); } } }