Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
513 views
Hi,

I am using the AjaxControlToolkit AutoCompleteExtender inside an ASP.NET AJAX RadGrid.  It works fine with the following code:

<script type="text/javascript" language="javascript">
    function GetDogID(source, eventArgs) {
        var DogIDTxt = document.getElementById('<%=DogIDTxt.ClientID%>');
        DogIDTxt.value = eventArgs.get_value();
    }
</script>
<telerik:GridTemplateColumn DataField="trialCode" HeaderText="trialCode"
            SortExpression="trialCode" UniqueName="trialCode">
            <EditItemTemplate>
                <asp:TextBox ID="trialCodeTextBox" runat="server" autocomplete="off" onKeyPress="KeyPress()"></asp:TextBox>
 <cc1:AutoCompleteExtender ID="trialCodeTextBox_AutoCompleteExtender" runat="server"
            DelimiterCharacters="" Enabled="True"
            ServicePath="/assets/webservice/DogList.asmx" TargetControlID="trialCodeTextBox"
            ServiceMethod="GetCompletionList" MinimumPrefixLength="2"
            CompletionSetCount="20" CompletionInterval="0" OnClientItemSelected="GetDogID"
        >
        </cc1:AutoCompleteExtender>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="trialCodeLabel" runat="server" Text='<%# Eval("trialCode") %>'></asp:Label>
            </ItemTemplate>
        </telerik:GridTemplateColumn>

I use a web service to pull a list of values from a database and all is well.

However...

I am using the OnClientItemSelected method (relatively new to AutoCompleteExtender so that I am able to pull back a value pair from the web service: 1.) the text value (which I'm displaying as 'autocomplete' in the RadGrid textbox while in edit mode and 2.) a primary key ID value of the item that i'm placing on a label control somewhere else on the page for now while i'm trying to figure out how to get it inside the RadGrid for use in updating.

What I need to do is be able to submit the update (or add a new record) from the RadGrid and use the primary key value on the page and NOT the text value pulled from the autocomplete.

The user needs to be able to select from a 'friendly' text-based list of about 3,000 items (hence, the need for autocomplete).  Then, once selected, the primary key (from the value pair that was returned from the web service) needs to be the value that the RadGrid inserts when making the update---not the text value as there could be duplicates.

Is this possible? 

Chris

Here's the web service i'm using:

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class DogList
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As String()
        Dim connString As String = ConfigurationManager.AppSettings("DataConnect2")
        Dim conn As New SqlConnection(connString)
        Dim mycommand As New SqlCommand
        Dim rs As SqlDataReader
        Dim items As New List(Of String)

        'we add the prefixText into our SQL query to retrieve the options
        'for our autocomplete
        Dim strsql As String = "SELECT registrationNumber, dogName + ' - #' + registrationNumber As 'TheDog' FROM Dogs WHERE dogName LIKE '" & Replace(prefixText, "'", "''") & "%' ORDER BY dogName ASC"
        mycommand.Connection = conn
        mycommand.CommandText = strsql

        Try
            conn.Open()
            rs = mycommand.ExecuteReader
            If rs.HasRows Then

                'we loop through the results adding each result to our list of
                'items
                Do While rs.Read
                    Dim thevalues As String = AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(rs("TheDog").ToString(), rs("registrationNumber").ToString())
                    items.Add(thevalues)
                Loop

            End If

        Catch ex As Exception
            items.Add(ex.ToString)
            ' this will show the exception in the autocomplete list if
            ' there are any errors
        Finally
            mycommand.Dispose()
            conn.Close()
            conn.Dispose()

        End Try
        Return items.ToArray ' we return our list of items as an array

    End Function




Suzy
Top achievements
Rank 2
 answered on 27 Jan 2015
3 answers
594 views
I am trying to use a control which will only allow users to select the Month and Year. BUT, I need to also not allow them to choose future dates based on todays date. I  am working in vb.net and had found this example, but cannot get it to work in vb. http://birenpanigrahi.blogspot.com/2013/11/radmonthyearpicker-validation-restrict.html

Any help would be greatly appreciated. I have also tried to use a RadDatePicker which I can restrict the future date based on todays date as the date changes, but I do not want the days to display for selection. If there is a way to only allow RadDatePicker to show Month and Year in the popup instead of Day, Months and Years, I would take that as well.

Thank you.
Vasil
Telerik team
 answered on 27 Jan 2015
2 answers
243 views
I'm trying to set the background color of the selected text area (ie: displayed when the drop down is closed) on the RadDropDownTree programmatically.

The screen has multiple RadDropDownTree controls, each of which the client can configure to be mandatory or optional, and when mandatory the client can also select for these to be displayed in a different color.   

Setting the dropdowntree.BackColor is not working (setting dropdowntree.EmbeddedTree.BackColor sets the drop down background which is not what we want).

I can set the area I need the background color applied to in the css with
.RadDropDownTree_WebBlue .rddtInner .rddtFakeInput
{
    background-image: none !important;
    background-color: White;
}

but need to do this on a control-by-control basis from the code behind.

Can you advise how I can go about this?
Nigel
Top achievements
Rank 1
 answered on 26 Jan 2015
4 answers
241 views
How remove the default toolbar in telerik:GridHTMLEditorColumn?
I just want to use my own buttons I create server side....
Kjell
Top achievements
Rank 1
Iron
Iron
 answered on 26 Jan 2015
5 answers
503 views
Hi Team,

I have a grid and it has some rows in it. I am implementing batch editing for this grid. I am using the DLL Version of 2014.3.1216.45

I need to implement duplicate record checking for this grid.

we have compartment index column in the grid. When the user clicks on add new record and he enter one for compartment index and second time also if he enter one for the compartment index and click on save changes button that time we need to check the duplicate record validation.


currently this duplicate checking I am doing it on the "OnBatchEditCellValueChanging" event of the grid.
But I need this implementation  when I click on save changes button.

Please see my code below.

<script type="text/javascript">

function valueChanging(sender, args) {

if (args.get_columnUniqueName() == "CompNo") {
var tableView = sender.get_masterTableView();
var batchManager = sender.get_batchEditingManager();
var items = tableView.get_dataItems();
var newValue = args.get_editorValue();
for (var i = 0; i < items.length; i++) {
var idCell = items[i].get_cell("CompNo");
var id = batchManager.getCellValue(idCell);
if (args.get_row() != items[i].get_element() && id == newValue) {
radconfirm(transMessages.SDP_ALERT_WHILE_UPDATE_LOAD_DETAIL, confirmCallBackFn);
}
}
}
}
</script>
<telerik:RadGrid ID="CompartmentLevelLoadRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
Height="233px" Width="475px" OnItemDataBound="CompartmentLevelLoadRadGrid_ItemDataBound" OnNeedDataSource="CompartmentLevelLoadingRadGrid_NeedDataSource"
OnBatchEditCommand="CompartmentLevelLoadRadGrid_BatchEditCommand" OnItemCreated="CompartmentLevelLoadRadGrid_ItemCreated">

<MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch" DataKeyNames="CompartmentIndex">
<CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add LineItem" />
<BatchEditingSettings EditType="Cell" />

<Columns>
<telerik:GridTemplateColumn HeaderText="Comp No." HeaderStyle-Width="30px" UniqueName="CompNo" DataField="CompartmentIndex">
<ItemTemplate>
<%# Eval("CompartmentIndex") %>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox runat="server" ID="ddlCompartment" OnLoad="ddlLoadCompartments" Width="50px" EmptyMessage="-Select-">
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="compartmentRequiredFieldValidator"
ControlToValidate="ddlCompartment" ErrorMessage="Compartment Required" runat="server" Display="Dynamic">
</asp:RequiredFieldValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn HeaderText="PriorTo Load" HeaderStyle-Width="30px" UniqueName="PriorToLoad" DataField="PTL">
<ItemTemplate>
<%# Eval("PTL") %>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadNumerictextbox runat="server" ID="txtPTL" Width="50px" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator="" MinValue="0" MaxValue="999999999">
</telerik:RadNumerictextbox>
<asp:RequiredFieldValidator ID="PTLRequiredFieldValidator"
ControlToValidate="txtPTL" ErrorMessage="PTL is Required" runat="server" Display="Dynamic">
</asp:RequiredFieldValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn HeaderText="Planned Product" HeaderStyle-Width="50px" UniqueName="PlannedLoadProd" DataField="PlannedProductName" ReadOnly="true" InsertVisiblityMode="AlwaysVisible">
<ItemTemplate>
<%# Eval("PlannedProductName") %>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox runat="server" ID="ddlPlannedProduct" OnLoad="ddlPlannedProductLoad" Width="70px" EmptyMessage="-Select-">
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="ActualProductName" HeaderText="Actual Product" UniqueName="ActualLoadProd" HeaderStyle-Width="50px" >
<ItemTemplate>
<%# Eval("ActualProductName") %>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox runat="server" ID="ddlActualProduct" OnLoad="ddlActualProductLoad" Width="70px">
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="actualProductValidator"
ControlToValidate="ddlActualProduct" ErrorMessage="ActualProd is Required" runat="server" Display="Dynamic">
</asp:RequiredFieldValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn DataField="PlannedQuantity" HeaderText="Planned Quantity" UniqueName="PlannedLoadQty" HeaderStyle-Width="50px" ReadOnly="true" InsertVisiblityMode="AlwaysVisible">
<ItemTemplate>
<%# Eval("PlannedQuantity") %>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadNumerictextbox runat="server" ID="txtPlannedQuantity" Width="60px" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator="" MinValue="0" MaxValue="999999999">
</telerik:RadNumerictextbox>
</EditItemTemplate>
</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn DataField="ActualQuantity" HeaderText="Actual Quantity" UniqueName="ActualLoadQty" HeaderStyle-Width="50px">
<ItemTemplate>
<%# Eval("ActualQuantity") %>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadNumerictextbox runat="server" ID="txtActualQuantity" Width="60px" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator="" MinValue="0" MaxValue="999999999">
</telerik:RadNumerictextbox>
<asp:RequiredFieldValidator ID="actualQuantityValidator"
ControlToValidate="txtActualQuantity" ErrorMessage="ActualQty is Required" runat="server" Display="Dynamic">
</asp:RequiredFieldValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>

</Columns>
</MasterTableView>
<ClientSettings>
<ClientEvents OnBatchEditCellValueChanging="valueChanging" />
</ClientSettings>

</telerik:RadGrid>         
                    
                    
Regards,
Sudhakar.
        
 


    


          
Angel Petrov
Telerik team
 answered on 26 Jan 2015
1 answer
211 views
So here is what I have today.  A menu that the user allows to open, inside of this I want them to be able to be able to search for an item, display some simple information about what was searched for.  If they want to see the full record there will be a link to send them to that record.  My issue is when I use the searchbox, the moment I select something it causes the menu to close.  If I open up the menu again, everything is there.  Here is my code thus far:

<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>

<telerik:RadMenu runat="server" ID="RadMenu1" Skin="Default" EnableShadows="true" BackColor="Green" ClickToOpen="true">
<Items>
<telerik:RadMenuItem PostBack="false" ImageUrl="/includes/images/menuSearch.png">
<ContentTemplate>
<div id="CatWrapper" class="Wrapper" style="width: 635px; height: 600px;">
<div style="width: 425px;">
SEARCH FOR ASSET
</div>

<telerik:RadSearchBox runat="server" ID="RadSearchBox1"
CssClass="searchBox" Skin="Silk"
Width="460" DropDownSettings-Height="300"
DataSourceID="sqlSearch"
DataTextField="description"
DataValueField="assetID"
DataKeyNames="asset_num,location,cost"
EmptyMessage="Search By Description"
Filter="StartsWith"
MaxResultCount="20"
OnSearch="RadSearchBox1_Search">
</telerik:RadSearchBox>

<div>
<asp:Label runat="server" ID="lblAsset" />
</div>
</div>

<asp:SqlDataSource ID="sqlSearch" runat="server" ConnectionString="<%$ ConnectionStrings:dbAll %>"
SelectCommand="SELECT * FROM assetMain"></asp:SqlDataSource>

</ContentTemplate>
</telerik:RadMenuItem>
</Items>
</telerik:RadMenu>

</ContentTemplate>
</asp:UpdatePanel>
Ivan Danchev
Telerik team
 answered on 26 Jan 2015
1 answer
158 views
How do I style the dragged item when using drag-and-drop with a RadTreeList? I am currently doing this by setting the OnItemDragging client event to call a Javascript function, then having that function call args.get_draggedContainer(), then setting the classname for the result, but it seems like there should be a simpler way. Is there a property I can set that will control the CSS class of a dragged item?
Eyup
Telerik team
 answered on 26 Jan 2015
3 answers
455 views
Trying to css the radmenu so that the menu items are split evenly across 100% of my screen.  I have a radmenu with 8 items but when I set the radmenu to 100% of the div, it goes 100% but the menu items do not split evently across it.  I tried putting a width of the menu items themsleves but they never get 100% of the screen and when I minimize the screen they wrap intead of minimizing with the screen.  Is there a way to do this or are we stuck with trying to get pixal widths to work.  Seems like this should be a standard feature in the control.


<table style="width:100%">
           <tr>
               <td style="text-align:center"><telerik:RadMenu ID="rdmenu" runat="server" OnItemClick="rdmenu_ItemClick" Width="100%"></telerik:RadMenu></td>
           </tr>
       </table>     
       <div style="width:100%">
           <telerik:RadTileList runat="server" ID="RadTileList1" SelectionMode="Multiple" OnSelectionChanged="RadTileList1_SelectionChanged" AutoPostBack="true" Skin="WebBlue" OnTileClick="RadTileList1_TileClick"></telerik:RadTileList>                         
           <asp:HiddenField ID="HFMenuId" runat="server"/>
       </div>
Ivan Danchev
Telerik team
 answered on 26 Jan 2015
3 answers
711 views
Hi,

RadGrid is configured with PagerStyle-Mode "NextPrevNumericAndAdvanced".  Goto Page and Page size controls are coming as expected.  
I want to display only Goto page but not Page Size controls.  Also I want to display Goto Page option right after the page numbers.  Please find attachment.  I am able to do it with css as follows:

.RadGrid .rgPager .rgAdvPart [id*="ChangePageSize"]
{
    display:none;
}
div.RadGrid .rgPager .rgAdvPart     
{     
    float:left;


  Do you have any property or method to do this?
Eyup
Telerik team
 answered on 26 Jan 2015
1 answer
127 views
Hi,

When I use a label with the drop down tree control it doesn't appear.  Other controls such as RadTextBox etc work fine with labels.  Is this a bug?  Very cut down code for the control is shown below and this fails:

<telerik:RadDropDownTree ID="RadDropDownTree3" Runat="server" Label="Parent Budget Group:" ></telerik:RadDropDownTree>

Any suggestions short of using a normal label control?

Regards

Jon
Nencho
Telerik team
 answered on 26 Jan 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?