Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
515 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
207 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
256 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
682 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
507 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
490 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
115 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
164 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
1 answer
112 views
Hello !
I use a RadSearchBox like this : http://demos.telerik.com/aspnet-ajax/searchbox/examples/overview/defaultcs.aspx.
And I search to have my result in First or a "auto-scroll" to go to my result.
I tried with onFocus and this code :  var typeSearchBox = $find("<%= RadSearchBox1.ClientID %>");
                                                          typeSearchBox = typeSearchBox.get_inputElement();
                                                           typeSearchBox.focus();

But I don't arrive. Do you have a idea ?
Ivan Danchev
Telerik team
 answered on 15 Sep 2016
4 answers
138 views
I am trying to format my CSV export from a radGrid. It exports fine but it doesn't seem to pick up any of the styles. This what I am using: 

protected void imgBtnExportCSV_Click(object sender, EventArgs e)
  {
    foreach (GridDataItem item in grdLeadList.MasterTableView.Items) //loop through each grid item
      {
        if (item.Selected)
          {
            selectedItems.Add(item.ItemIndex);
          }
      }
 
foreach (GridDataItem item in grdLeadList.MasterTableView.Items)
  {
    // for particuler item
    item["CompanyName"].Font.Name = "Calibri";
    item["CompanyName"].Style["font-size"] = "8pt";
    item["CompanyName"].Style["background-color"] = "#FFF";
    item["CompanyName"].Style["vertical-align"] = "middle";
  }
  grdLeadList.ExportSettings.ExportOnlyData = true;
  grdLeadList.ExportSettings.OpenInNewWindow = true;
                grdLeadList.MasterTableView.Columns.FindByUniqueName("ClientSelectColumn").Visible = false;
            grdLeadList.MasterTableView.Columns.FindByUniqueName("EditCommandColumn1").Visible = false;
            grdLeadList.ExportSettings.FileName = "ColderLeads";
            grdLeadList.MasterTableView.ExportToCSV();
 
  }


Is it possible to format CSV export from radGrid?

Thanks!

Danniel
Top achievements
Rank 1
 answered on 14 Sep 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?