I was curious if there was a way to add a radcombobox with load on demand abilities within an exisiting radgrid. I really just need to have it that when you start typing it will then populate any items that start with the letter/numbers you are typing dynamically. For example, if I typed Batt it would autofill Battery or if I had done Serial Number it would populate all that apply. I have seen it outside of a grid but not within. In the picture below would like to have the asset_type autofill options from database that are in the asset_type column. Any examples would be great.
Imports System.Data Imports System.Data.SqlClient Imports System.Drawing Imports System.Web.UI Imports System.Configuration Imports System.Web.UI.WebControls Imports Telerik.Web.UI Partial Class RadGridEditCustomValidatorVB Inherits Page ' Page Load event Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then RadGrid.Rebind() End If End Sub ' Bind the grid to the data source Protected Sub RadGrid_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) RadGrid.DataSource = GetGridSource() End Sub ' Get data from the database Private Function GetGridSource() As DataTable Dim dataTable As New DataTable() ' Get the connection string from the web.config file Dim connectionString As String = ConfigurationManager.ConnectionStrings("Data_WarehouseConnectionString_PRODUCTION").ConnectionString Using connection As New SqlConnection(connectionString) Dim query As String = "SELECT [ID], [Asset_type], [PortalID], [asset_SN], [asset_model], [Maint_Date], [Fill_qty], [asset_location], [Active_indicator], [Asset_Notes] FROM [data_warehouse].[dbo].[ATracker]" Using command As New SqlCommand(query, connection) Using adapter As New SqlDataAdapter(command) adapter.Fill(dataTable) End Using End Using End Using Return dataTable End Function Protected Sub RadGrid_ItemCreated(sender As Object, e As GridItemEventArgs) If e.Item.IsInEditMode Then Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem) ' Add validator for Asset_type (Non-nullable) Dim assetTypeEditor As GridTextBoxColumnEditor = CType(item.EditManager.GetColumnEditor("Asset_type"), GridTextBoxColumnEditor) AddRequiredFieldValidator(assetTypeEditor.TextBoxControl, "Asset Type") ' Add validator for PortalID (Non-nullable) Dim portalIDEditor As GridTextBoxColumnEditor = CType(item.EditManager.GetColumnEditor("PortalID"), GridTextBoxColumnEditor) AddRequiredFieldValidator(portalIDEditor.TextBoxControl, "PortalID") ' Add validator for asset_sn (Non-nullable) Dim assetSNEditor As GridTextBoxColumnEditor = CType(item.EditManager.GetColumnEditor("asset_SN"), GridTextBoxColumnEditor) AddRequiredFieldValidator(assetSNEditor.TextBoxControl, "Asset Serial Number") ' Add validator for asset_model (Non-Nullable) Dim assetModelEditor As GridTextBoxColumnEditor = CType(item.EditManager.GetColumnEditor("asset_model"), GridTextBoxColumnEditor) AddRequiredFieldValidator(assetModelEditor.TextBoxControl, "Asset Model") ' Add validator for asset_location (Nullable) Dim assetLocEditor As GridTextBoxColumnEditor = CType(item.EditManager.GetColumnEditor("asset_location"), GridTextBoxColumnEditor) AddRequiredFieldValidator(assetLocEditor.TextBoxControl, "Location") ' Add validator for Fill_qty (Nullable but must be numeric if provided) Dim fillQtyEditor As GridTextBoxColumnEditor = CType(item.EditManager.GetColumnEditor("Fill_qty"), GridTextBoxColumnEditor) AddNumericValidator(fillQtyEditor.TextBoxControl, "Fill Quantity") Dim buttonName As String = If(TypeOf item Is IGridInsertItem, "PerformInsertButton", "UpdateButton") TryCast(item.FindControl(buttonName), Button).ValidationGroup = "gridFormValidation" End If End Sub Private Sub AddRequiredFieldValidator(textBox As TextBox, fieldName As String) Dim validator As New CustomValidator() validator.ID = "CustomValidator_" & fieldName.Replace(" ", "_") validator.ControlToValidate = textBox.ID validator.ValidateEmptyText = True validator.ErrorMessage = String.Format("* {0} is required", fieldName) validator.ForeColor = Color.OrangeRed validator.ClientValidationFunction = "requiredFieldValidation" validator.ValidationGroup = "gridFormValidation" AddHandler validator.ServerValidate, AddressOf RequiredField_ServerValidate textBox.Parent.Controls.Add(validator) End Sub Private Sub AddNumericValidator(textBox As TextBox, fieldName As String) Dim validator As New CustomValidator() validator.ID = "CustomValidator_" & fieldName.Replace(" ", "_") validator.ControlToValidate = textBox.ID validator.ValidateEmptyText = False validator.ErrorMessage = String.Format("* {0} must be numeric", fieldName) validator.ForeColor = Color.OrangeRed validator.ClientValidationFunction = "numericFieldValidation" validator.ValidationGroup = "gridFormValidation" AddHandler validator.ServerValidate, AddressOf NumericField_ServerValidate textBox.Parent.Controls.Add(validator) End Sub Protected Sub RequiredField_ServerValidate(source As Object, args As ServerValidateEventArgs) args.IsValid = Not String.IsNullOrWhiteSpace(args.Value) End Sub Protected Sub NumericField_ServerValidate(source As Object, args As ServerValidateEventArgs) Dim result As Decimal args.IsValid = Decimal.TryParse(args.Value.Trim(), result) End Sub Protected Sub RadGrid_ItemCommand(sender As Object, e As GridCommandEventArgs) If e.CommandName = RadGrid.UpdateCommandName Or e.CommandName = RadGrid.PerformInsertCommandName Then If Page.IsValid Then Dim editableItem As GridEditableItem = TryCast(e.Item, GridEditableItem) 'Runs Validation Code from RequiredField_ServerValidate and NumericField_ServerValidate Dim txtAssetType As TextBox = CType(editableItem("Asset_type").Controls(0), TextBox) Dim txtPortalID As TextBox = CType(editableItem("PortalID").Controls(0), TextBox) Dim txtSerialNum As TextBox = CType(editableItem("asset_SN").Controls(0), TextBox) Dim txtFillQty As TextBox = CType(editableItem("Fill_qty").Controls(0), TextBox) Dim rdpMaintDate As RadDatePicker = CType(editableItem("Maint_Date").Controls(0), RadDatePicker) Dim txtLocation As TextBox = CType(editableItem("asset_location").Controls(0), TextBox) Dim txtModel As TextBox = CType(editableItem("asset_model").Controls(0), TextBox) Dim chkActive As CheckBox = CType(editableItem("Active_indicator").Controls(0), CheckBox) Dim txtNotes As TextBox = CType(editableItem("Asset_Notes").Controls(0), TextBox) Dim objConnection As SqlConnection Dim strSQL As String objConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Data_WarehouseConnectionString_PRODUCTION").ConnectionString) 'Testing DB connection 'objConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("masterConnectionString").ConnectionString) 'Determine if we are updating or inserting If e.CommandName = RadGrid.UpdateCommandName Then strSQL = "UPDATE [data_warehouse].[dbo].[ATracker] SET [Asset_type] = @asset_type, [PortalID] = @PortalID, [asset_SN] = @AssetSN, [Fill_qty] = @FillQty, [Maint_Date] = @MaintDate, [asset_location] = @Location, [asset_model] = @Model, [Active_indicator] = @Active, [Asset_Notes] = @Notes WHERE [ID] = @ID" Else strSQL = "INSERT INTO [data_warehouse].[dbo].[ATracker] ([Asset_type], [PortalID], [asset_SN], [Fill_qty], [Maint_Date], [asset_location], [asset_model], [Active_indicator], [Asset_Notes]) VALUES (@asset_type, @PortalID, @AssetSN, @FillQty, @MaintDate, @Location, @Model, @Active, @Notes)" End If 'Add parameters to the SQL command Dim cmd As New SqlCommand(strSQL, objConnection) cmd.Parameters.Add("@asset_type", SqlDbType.VarChar, 20).Value = txtAssetType.Text cmd.Parameters.Add("@ID", SqlDbType.Int).Value = If(e.CommandName = RadGrid.UpdateCommandName, editableItem.GetDataKeyValue("ID"), DBNull.Value) cmd.Parameters.Add("@PortalID", SqlDbType.VarChar, 10).Value = txtPortalID.Text cmd.Parameters.Add("@AssetSN", SqlDbType.VarChar, 20).Value = txtSerialNum.Text cmd.Parameters.Add("@FillQty", SqlDbType.Int).Value = If(String.IsNullOrEmpty(txtFillQty.Text), DBNull.Value, Convert.ToInt32(txtFillQty.Text)) cmd.Parameters.Add("@MaintDate", SqlDbType.Date).Value = If(rdpMaintDate.SelectedDate Is Nothing, DBNull.Value, rdpMaintDate.SelectedDate) cmd.Parameters.Add("@Location", SqlDbType.VarChar, 20).Value = txtLocation.Text cmd.Parameters.Add("@Model", SqlDbType.VarChar, 20).Value = txtModel.Text cmd.Parameters.Add("@Active", SqlDbType.Bit).Value = chkActive.Checked cmd.Parameters.Add("@Notes", SqlDbType.VarChar, -1).Value = txtNotes.Text Try objConnection.Open() cmd.ExecuteNonQuery() Catch ex As Exception System.Console.WriteLine(ex.ToString()) Finally objConnection.Close() End Try RadGrid.Rebind() Else e.Canceled = True End If End If End Sub 'CANT GET THIS TO TRIGGER Protected Sub RadGrid_ItemDeleted(sender As Object, e As GridCommandEventArgs) If e.CommandName = RadGrid.DeleteCommandName Then Dim item As GridDataItem = TryCast(e.Item, GridDataItem) If item IsNot Nothing Then ' Find the hidden field in the grid data item where ID is bound Dim atID As Integer = Convert.ToInt32(item.OwnerTableView.DataKeyValues(item.ItemIndex)("ID")) Dim objConnection As SqlConnection Dim strSQL As String objConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Data_WarehouseConnectionString_PRODUCTION").ConnectionString) ' SQL command to delete the record where ID matches strSQL = "DELETE FROM [data_warehouse].[dbo].[ATracker] WHERE [ID] = @ID" Dim cmd As New SqlCommand(strSQL, objConnection) cmd.Parameters.Add("@ID", SqlDbType.Int).Value = atID Try objConnection.Open() cmd.ExecuteNonQuery() Catch ex As Exception System.Console.WriteLine(ex.ToString()) Finally objConnection.Close() End Try End If RadGrid.Rebind() End If End Sub 'Show a dropdown list of the asset types in the database Protected Sub RadGrid_ItemDataBound(sender As Object, e As GridItemEventArgs) If e.Item.IsInEditMode Then Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem) If Not (TypeOf e.Item Is IGridInsertItem) Then Dim combo As RadComboBox = DirectCast(item.FindControl("Asset_type"), RadComboBox) Dim preselectedAsset As New RadComboBoxItem() preselectedAsset.Text = item("Asset_type").Text preselectedAsset.Value = item("Asset_type").Text combo.Items.Insert(0, preselectedAsset) End If End If End Sub End Class
<form id="form1" runat="server">
<telerik:RadStyleSheetManager ID="RadStyleSheetManager2" runat="server"></telerik:RadStyleSheetManager>
<telerik:RadScriptManager ID="RadScriptManager2" runat="server"></telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid" runat="server" AllowPaging="True" Width="800px"
OnNeedDataSource="RadGrid_NeedDataSource" OnItemCommand="RadGrid_ItemCommand" onitemdatabound="RadGrid_ItemDataBound"
OnItemCreated="RadGrid_ItemCreated" OnDeleteCommand="RadGrid_ItemDeleted" Skin="MetroTouch">
<GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="ID">
<RowIndicatorColumn ShowNoSortIcon="False"></RowIndicatorColumn>
<ExpandCollapseColumn ShowNoSortIcon="False"></ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="ID" DataType="System.Int32" FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID" Visible="False"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Asset_type" FilterControlAltText="Filter Asset_type column" HeaderText="Asset_type" SortExpression="Asset_type" UniqueName="Asset_type" ></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="PortalID" FilterControlAltText="Filter PortalID column" HeaderText="PortalID" SortExpression="PortalID" UniqueName="PortalID"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="asset_SN" FilterControlAltText="Filter asset_SN column" HeaderText="Serial Number" SortExpression="asset_SN" UniqueName="asset_SN"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="asset_model" FilterControlAltText="Filter asset_model column" HeaderText="Model" SortExpression="asset_model" UniqueName="asset_model"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="asset_location" FilterControlAltText="Filter asset_location column" HeaderText="Location" SortExpression="asset_location" UniqueName="asset_location"></telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="Maint_Date" FilterControlAltText="Filter Maint_Date column" HeaderText="Date of Service" SortExpression="Maint_Date" UniqueName="Maint_Date"></telerik:GridDateTimeColumn>
<telerik:GridBoundColumn DataField="Fill_qty" FilterControlAltText="Filter Fill_qty column" HeaderText="Fill Qty (Gallons)" SortExpression="Fill_qty" UniqueName="Fill_qty"></telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn DataField="Active_indicator" DataType="System.Boolean" FilterControlAltText="Filter Active_indicator column" HeaderText="Active?" SortExpression="Active_indicator" UniqueName="Active_indicator"></telerik:GridCheckBoxColumn>
<telerik:GridBoundColumn DataField="Asset_Notes" FilterControlAltText="Filter Notes column" HeaderText="Notes" SortExpression="Asset_Notes" UniqueName="Asset_Notes"></telerik:GridBoundColumn>
<telerik:GridEditCommandColumn EditText="Edit" />
<telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this record?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" CommandName="Delete" Text="Delete" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
</form>
I want to change the imagerySet of the bing maps layer code behind when postback? How?
ImagerySet="road" / ImagerySet="aerialWithLabels"......
I think the following skins should not be used with the Classic render mode.
Material, MetroTouch, BlackMetroTouch, Bootstrap, Silk, Glow
But I'm not sure if this is correct since I could not find any documentation on this matter.
I'm mapping locations. some times companies have multiple assets at the same address or same Longitude/Latitude. When this is rendered on the map it shows up as one pin and all the rest get lost in the ether. I ran across some Kendo example that is supposed to pad the pins. It doesn't work. How do we get multiple pins to render at the same location or how do we get one pin to show multiple sets of data?
Map code is pretty simple:
<telerik:RadMap RenderMode="Lightweight" runat="server" ID="mapSite" Zoom="4" CssClass="MyMap Rounded" Width="100%" Height="100%">
<DataBindings>
<MarkerBinding DataShapeField="Shape" DataTitleField="SITE_CITY" DataLocationLatitudeField="Latitude" DataLocationLongitudeField="Longitude" />
</DataBindings>
<LayersCollection>
<telerik:MapLayer Type="Tile" Subdomains="a,b,c"
UrlTemplate="https://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png"
Attribution="">
</telerik:MapLayer>
</LayersCollection>
</telerik:RadMap>
Code behind:
Binding code:
Dim res = From x In db.SITEs
Where x.COMPANY.COMPANY_CODE.Equals(Session("Market").ToString)
Select New clsSiteData With {
.Shape = "PinTarget",
.SITE_ID = x.SITE_ID,
.SITE_CODE = x.SITE_CODE,
.SITE_NAME = x.SITE_NAME,
.SITE_ADDRESS_1 = x.SITE_ADDRESS_1,
.SITE_ADDRESS_2 = x.SITE_ADDRESS_2,
.SITE_CITY = x.SITE_CITY,
.STATE_CODE = x.STATE.STATE_CODE,
.POSTAL_CODE = x.SITE_POSTAL_CODE,
.BUILDING_ID = x.SITE_BUILDING_IDENTIFIER,
.PROPERTY_ID = x.PROPERTY_CODE.PROPERTY_CODE,
.Latitude = If(x.SITE_MAP_LAT, 0),
.Longitude = If(x.SITE_MAP_LON, 0)
}
mapSite.DataSource = res.ToList
mapSite.DataBind()
ItemDataBound:
Private Sub mapSite_ItemDataBound(sender AsObject, e As MapItemDataBoundEventArgs) Handles mapSite.ItemDataBound
Dim htmlTemplate AsStringTry
hlAssInv.Visible = CType(ViewState("Asset"), Boolean)
htmlTemplate = getInnerHTML(tblTemplate)
Dim marker As MapMarker = TryCast(e.Item, MapMarker)
If marker IsNothingThenReturnEndIfDim item As clsSiteData = TryCast(e.DataItem, clsSiteData)
marker.TooltipSettings.Content = [String].Format(htmlTemplate,
item.SITE_CODE,
item.SITE_NAME,
item.SITE_ADDRESS_1,
item.SITE_ADDRESS_2,
item.SITE_CITY,
item.STATE_CODE,
item.POSTAL_CODE,
item.BUILDING_ID,
item.PROPERTY_ID,
item.SITE_ID)
Catch ex As Exception
Dim xxx AsString = ex.Message.ToString
End Try
End Sub
When Static header are enabled and few columns are fixed,
Scenario:
1.If the Start and End Dates range are more than 1 month, the data is not exactly aligned with the Header dates after scrolling towards right.
2.If filter is applied, then the footer is displayed at very bottom.
Hello, as I read from https://docs.telerik.com/devtools/aspnet-ajax/controls/editor/functionality/track-changes-and-comments/track-changes#supported-commands only some track change commands are available.
For example, Delete row or column is not tracking.
So, I wanted to create workaround, which cancels row deletion and instead remove content of the cells (in TrackChange mode just mark as deleted).
I just have the following idea, but it is not delete text:
function OnClientCommandExecuting(editor, args) {
var commandName = args.get_commandName();
var tool = args.get_tool();
var value = args.get_value();
if (commandName === "DeleteRow") {
args.set_cancel(true);
var range = editor.getSelection().getRange();
var tableRow = range.commonAncestorContainer;
while (tableRow && tableRow.tagName !== "TR") {
tableRow = tableRow.parentNode;
}
if (tableRow) {
var cells = tableRow.cells;
for (var i = 0; i < cells.length; i++) {
var cellContent = cells[i].innerHTML;
var cellRange = editor.get_document().createRange();
cellRange.selectNodeContents(cells[i]);
editor.getSelection().selectRange(cellRange);
editor.executeCommand("Backspace", false, true);
}
}
}
}
Any ideas to fix? Is it more easy solution? May be add to TR attribute "data-del" and define it in css? Is it possible to resolve it in backend?
Thank you!
Telerik has the little Kendo ninja fellow as a constant icon on the bottom right of the window, and after a few seconds, it slides out to ask "Is this article helpful? Yes/No".
My client wants a timed pop-out similar to that on each page, which after 10-15 seconds asks "Do you want more information? Click here to contact us!" and then redirect to our contact page. Or they can click to make it hide away (until the next page).
I'm suspecting the Notification widget will do this, but I'm not sure where to begin or if there is something better for this purpose. Has anyone done something like this?
Hello,
Is any way to return:
1. Html with Track Change marks and comments to store it in the database for next edit session?
2. Auto accepted html.
I tried in cs: RadEditor1.Content - but it return content without changes, RadEditor1.GetHtml(EditorStripHtmlOptions.AcceptTrackChanges) - but also track changes were not accepted.
Can you provide any example, please?
Thank you!
We have hundreds of log error messages regarding missing or problem loading ButtonSprites.gif.
This issue has been asked in 2019 ticket and we were informed it would be fixed in a new release. It has yet to be fixed, and although I we are not experiencing any obvious issues, other than the error in the log, I have been tasked with resolving this.
The exact message states: "The requested resource 'pTelerik.Web.UI.Skins|Telerik.Web.UI.Skins.Sunset.FormDecorator.ButtonSprites.gif' does not exist or there was a problem loading it."
Please advise.
For reference, see our ticket #1453479
Thank you,
Jeff.