Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
161 views

Hello I am trying to have a RadMaskedTextBox allow the user to type an SSN, with the caveat that they must be allowed to hit spacebar (whitespace) or the prompt character X.  The idea is to  have a wildcard search.

So I tried with the simple example:

<telerik:RadMaskedTextBox ID="txtSearchSSN" DisplayMask="XXX-XX-XXXX" Mask="###-##-####" PromptChar="X" runat="server" />

However this did *not* allow whitespace like the documentation suggested, and instead would fire a validator off in the control and disallow it.  So I rewrote it lengthier but more explicit so it will include a range from 0-9, X, or a whitespace, like this:

<telerik:RadMaskedTextBox ID="txtSearchSSN" DisplayMask="XXX-XX-XXXX" Mask="<0|1|2|3|4|5|6|7|8|9| |X><0|1|2|3|4|5|6|7|8|9| |X><0|1|2|3|4|5|6|7|8|9| |X>-<0|1|2|3|4|5|6|7|8|9| |X><0|1|2|3|4|5|6|7|8|9| |X>-<0|1|2|3|4|5|6|7|8|9| |X><0|1|2|3|4|5|6|7|8|9| |X><0|1|2|3|4|5|6|7|8|9| |X><0|1|2|3|4|5|6|7|8|9| |X>" PromptChar="X" AllowEmptyEnumerations="true" runat="server"  />

Now it appears to validate and handle the way I would want, but now whenever I use spacebar (whitespace) to indicate a wildcard it changes the input value to Zero (0) rather than leaving it as the prompt character X.

Am I missing something obvious with this control to do what I want?

So if the user types 548 and then all X or Spaces, I want it to show in the input box as 548-XX-XXXX, but now it shows 548-00-0000 if I use spaces.  Using X as input has it showing properly though.

Any help is appreciated

Thanks!

Maria Ilieva
Telerik team
 answered on 15 Sep 2016
1 answer
72 views

So I have a hierarchical RadGrid with 1 master table and 1 detail table.

The detail table has the property 

<EditFormSettings EditFormType="Template">

The TemplateForm has 1 TextBox and 1 RadAsyncTable and the submit button (insert, update).

Now when I choose a file to upload and hit "insert" the file is uploaded and everything works correctly.

The problem is that when the file exists, I want to display an error message : "the file already exists". So I have a method to verify if the file exists. If this is the case, I want to keep the EditForm opened and display the error message. But when I choose another file that doesn't exist and hit submit again, it looks like the RadAsyncUpload loses its value and the file is gone.

Here is my code:

try {
 UploadedFile file = btn.UploadedFiles[0];
 bool exists = BDD.CheckIfDocumentExists(fileName);
 if (!exists) file.SaveAs(Path.Combine(targetFolder, fileName));
} catch (Exception ex) {
  // log the error
}
 
if (exists) {
 GridEditableItem item = (GridEditableItem) e.Item;
 Label RadTextBox1 = (Label) item.FindControl("lbl_detailerror");
 RadTextBox1.Text = "the file already exists";
 e.Canceled = true;
} else {
 // insert the file in db
}

Konstantin Dikov
Telerik team
 answered on 15 Sep 2016
2 answers
463 views
I have a RadGrid with two date columns and I have added a Calculated Column to get the number of days between them.

I tried a couple of techniques I found from Google to display the number of days but it always displays in this format:  2.00:00:00 for two days.  Fourty days looks like 40.00:00:00.  I just want to display the number of days as an integer like, "2" or "40".

The Calculated column UniqueName="DaysOpen".

One of the techniques I tried did the calculation in the .vb file and was supposed to send the value to a GridTemplateColumn with a <asp:Label /> in the ItemTemplate, but that method didn't work at all.  The column showed no values at all.  The column was there but all the fields were blank.
.aspx
        <telerik:GridCalculatedColumn DataFields="DateResolved,DateReceived" Expression="{0}-{1}" headerstyle-width="50px"
            HeaderText="Days Open" UniqueName="DaysOpen"  Aggregate="None">
        </telerik:GridCalculatedColumn>
 
 
<%--
        <telerik:GridTemplateColumn UniqueName="Temp" HeaderStyle-Width="50px" HeaderText="days open">
            <ItemTemplate>
              <asp:Label ID="DaysOpen" runat="server"></asp:Label>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
--%>


.aspx.vb  -  I commented out both methods because neither of them seemed to do anything.  In or out made no difference to the grid contents at all like they just weren't accessing the grid objects, which is probably the case.  On line 27 I hard coded a "3" in place of the now commented out, [date].ToString and the column was still blank.
Imports Telerik.Web.UI
Partial Class test
    Inherits System.Web.UI.Page
 
    'Protected Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
    '    'grid.MasterTableView.SwapColumns("ComplaintID", "DateReceived")
    'End Sub
 
    'Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    '    If TypeOf e.Item Is GridDataItem Then
    '        Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
    '        Dim myTS As TimeSpan = TimeSpan.Parse(item("DaysOpen").Text)
    '        item("DaysOpen").Text = [String].Format("{0}h {1}m {2}s", myTS.Days, myTS.Hours, myTS.Minutes)
    '    End If
    'End Sub
 
    '  Both methods of getting the difference between two dates work equally well.
    '  Actually neither of them seem to do shit. When I commented them both out I still got the same correct results, but formatted like this:  2.00:00:00 for two days.
 
    'Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    '    If TypeOf e.Item Is GridDataItem Then
    '        Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
    '        Dim DaysOpen As Label = TryCast(item.FindControl("DaysOpen"), Label)
    '        Dim DateResolved As String = (item("DateResolved").Text)
    '        Dim DateReceived As String = (item("DateReceived").Text)
    '        Dim [date] As Integer = Convert.ToDateTime(DateResolved).Subtract(Convert.ToDateTime(DateReceived)).Days
    '        DaysOpen.Text = "3" ' [date].ToString()
    '    End If
    'End Sub
 
End Class

With my markup and code just as above the DaysOpen column displayes the correct number of days, just in the long format.  I just want to display it as an integer. e.g. "40" not "40.00:00:00"

Thank you!
Meir
Top achievements
Rank 1
 answered on 15 Sep 2016
8 answers
176 views

Hi,

I have a Radgrid with 2 columns freeze and I have enabled the resize columns, Am dynamically populating the grid, The problem is When the columns are more By deafult horizontal scrollbar appears and freezing works fine,But when we have less columns then columns get fixed accordingly and horizontal scrollbar doesnot appear which is correct..However for that less columns when we resize columns horizontal scrollbar appears then freezing doesnot work.
Ultimately Freezing works fine when the horizonatl scrollbar appear by default but doesnot work when we resize columns and horizontal scrollbar appear.
So is there any workaround for this?

Viktor Tachev
Telerik team
 answered on 15 Sep 2016
5 answers
221 views
Hi,

I have a user control in which I am using a RadTabStrip & RadGrid. On tab click I have to update the grid. 

So to ajaxify I am using RadAjaxManager as below
<telerik:RadAjaxManager ID="radAjaxMgr" runat="server" EnableAJAX="true" EnablePageHeadUpdate="false" EnableViewState="false" >
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="radTabStripInd">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="radTabStripInd" />
                    <telerik:AjaxUpdatedControl ControlID="radGrid" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

When I click on the tab for first time the grid gets refreshed but after that none of the tab click event fire. But when I remove "radTabStripInd" from updated controls the grid refreshes for every tab selection but radTabStrip tab does not change to selected state.

Note: If i use a RadAjaxManager on a master page and RadAjaxManagerProxy on usercontrol everything works but I see the performance issue ( 6 -8 sec to refresh the grid).

Can you please let me know how to fix this issue?

Regards,
Kalyan


Viktor Tachev
Telerik team
 answered on 15 Sep 2016
11 answers
625 views
Hello,
I have added custom functionality to my RadGrid to persist grid column visibility when user toggles column visibility from "Columns" context menu.
So whenever user comes back to that page, same columns are displayed as last time.

I am applying persisted settings in Grid prerender event by calling following function:
        private void ApplyGridSettings()
        {
            var persistenceHelper = new PersistenceHelper();
            var settings = persistenceHelper.GetGridPersistenceSettings(this.ClientID);
            if (settings != null)
            {
                foreach (var columnSetting in settings.ColumnsSettings)
                {
                    var column = this.Columns.FindByUniqueNameSafe(columnSetting.Column);
                    if (column != null)
                    {
                        column.Display = columnSetting.Visible;
                    }
                }
            }
        }

Now I have added a header context menu "Reset Columns" to remove persisted settings and reset grid columns to default visibility.
I am calling following code on HeaderMenu click:

        private void HeaderContextMenu_ItemClick(object sender, RadMenuEventArgs e)
        {
            switch (e.Item.Text)
            {
                case "Reset Columns":
                    var persistenceHelper = new PersistenceHelper();
                    persistenceHelper.ResetGridColumns(this.ClientID);
                    this.MasterTableView.EnableColumnsViewState = false;
                    this.MasterTableView.Rebind();
                    break;

                default:
                    break;
            }
        }

I thought after rebinding the grid will reset grid columns, but it is not working.
Can anyone please suggest how to reset grid columns visibility?
Konstantin Dikov
Telerik team
 answered on 15 Sep 2016
14 answers
448 views
I have a standard RadListBox setup with 2 List Boxes.   The issue is need to limit the number of items that can be Transferred or Drag and Dropped into RadListBox2 to a maximum of 10 items.   RadListBox1 has a list of up to 100 items.  The issue is I need visitors to be able to pick up to 10, but no more than 10 items from List 1 and put them into List 2.

Is there any way to set maximum number of items on a RadListBox.   Or,  can you suggest javascript to check count and cancel the transfer or DragDrop if the count of the items in ListBox2 > 10 (along with an alert to let the user know what is wrong).

Thanks for any assistance.
Nencho
Telerik team
 answered on 15 Sep 2016
3 answers
444 views
Hai,

i got one problem in radsearcchbox when i select any item in search box OnSearch event will rise and some dropdowns will bind based on Radsearchbox item now i got one problem when i remove that item in Radsearchbox i want to remove all the items in dropdowns 
<cc1:RadSearchBox  runat="server" ID="cmbItemMaster" OnClientDataRequesting="OnClientSearch"
                                       OnSearch="cmbItemMaster_Search" Skin="WebBlue" Style="padding-right: 5px; padding-left: 5px; font-family: Calibri;"
                                               Width="85%" AutoPostBack="true" ZIndex="10000000" DropDownSettings-Width="200px" DropDownSettings-Height="200px">
                                           </cc1:RadSearchBox>
protected void cmbItemMaster_Search(object sender, SearchBoxEventArgs e)
        {
          
                ddlMaterialCode.Items.Clear();
                LoadMaterialCodes(e.Value);
               
            }


when i remove the selected item in radsearchbox the ddlMaterialCode will not show means the dropdown items of ddlMaterialCode is empty and after seleccting radsearchbox item then only it will bind how to do it sir
Peter Milchev
Telerik team
 answered on 15 Sep 2016
3 answers
97 views

Hi,

this Telerik support page claims that I can enable WAI-ARIA support by using the EnableAriaSupport property.

But I cannot find this property on my radPanelBar ASP.NET control (see attachment).

How can I enable WAI-ARIA support for all Telerik ASP.NET controls? (I particularly need it for the TreeView control, too.)

Peter Milchev
Telerik team
 answered on 15 Sep 2016
4 answers
148 views

Hi Telerik support

I want my radlistbox scoll to selected item as code bellow

I test this  code , it was working fire when i click the btnRefresh, pls tell me how to force the radlistbox scroll to selected item after searching finish on RadSearchBox RadIPSearch, after searching, the radlistbox will select the item found, but i want to scroll to it also

Thanks very much

 

<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableScriptCombine="false"></telerik:RadScriptManager>

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">

  <div>
                     <telerik:RadSearchBox ID="RadIPSearch" runat="server"
                            EmptyMessage="Search..." Width="135" OnSearch="RadIPSearch_Search">
                            <DropDownSettings Height="400" Width="200" />
                        </telerik:RadSearchBox>


                        <telerik:RadButton ID="btnRefresh" runat="server" Text="Refresh"
                            OnClientClicked="OnClientClicked"
                            ButtonType="SkinnedButton" AutoPostBack="false" OnClick="btnRefresh_Click">
                        </telerik:RadButton>
                    </div>

                    <div>
                        <telerik:RadListBox ID="lstIPAddress" runat="server"
                            Height="510px" Width="200px" AutoPostBack="True"
                            OnSelectedIndexChanged="lstIPAddress_SelectedIndexChanged">
                            <ButtonSettings TransferButtons="All" />
                        </telerik:RadListBox>
                    </div>

 <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

                <script type="text/javascript">
                    function OnClientClicked(sender, args) {
                        var listbox = $find("<%=lstIPAddress.ClientID %>");
                        listbox.get_selectedItem().scrollIntoView();
                    }
                </script>
            </telerik:RadCodeBlock>
    </telerik:RadAjaxPanel>
    </telerik:RadAjaxPanel>

 

 

 protected void RadIPSearch_Search(object sender, SearchBoxEventArgs e)
        {

            if (lstIPAddress.Items.Select(x => x.Text).ToList().Contains(e.Text))
            {
                lstIPAddress.SelectedIndex = lstIPAddress.Items.Where(x => x.Text == e.Text).FirstOrDefault().Index;

                // how to fire radlistbox to scroll to selected item here
            }
       
        }

 

 

Anton
Telerik team
 answered on 15 Sep 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?