Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
546 views

I use RadGrid a lot, so this one is mystifying me.

I have a RadGrid with a GridTemplateColumn which contains a button.  The first time I click on the button I get a postback, but the ItemCommand handler is not triggered.  However, if I click the button a second time the ItemCommand handler does get executed (which redirects to a new page so I don't get a third chance to try clicking the button).

The only thing unusual about this RadGrid is that the columns are dynamically created. 

Here is the RadGrid Markup

<telerik:RadGrid ID="dgDevices" runat="server" ShowGroupPanel="False" AllowPaging="true"
          ItemStyle-BackColor="#ffe394" BackColor="White" Visible="true" Height="200" PageSize="25"           
          Skin="Office2010Black" AllowSorting="false" AutoGenerateColumns="false" BorderWidth="0px"
          Width="1000" AllowCustomPaging="False"  OnNeedDataSource="dgDevices_NeedDataSource" OnItemCommand="dgDevices_ItemCommand">
 
          <AlternatingItemStyle BackColor="White" />
          <ExportSettings ExportOnlyData="True" IgnorePaging="true" OpenInNewWindow="true"
              HideStructureColumns="true">
          </ExportSettings>
          <ClientSettings AllowColumnHide="True" AllowColumnsReorder="True" AllowGroupExpandCollapse="True"
              ReorderColumnsOnClient="True" AllowDragToGroup="False">
              <Scrolling AllowScroll="False" UseStaticHeaders="True" />
              <Resizing AllowColumnResize="true" AllowRowResize="true" />
          </ClientSettings>
          <GroupingSettings ShowUnGroupButton="False" />
          <PagerStyle AlwaysVisible="true" Position="TopAndBottom" />
           
          <MasterTableView TableLayout="Fixed" CommandItemDisplay="Top"   UseAllDataFields="true"  >
              <NoRecordsTemplate><br />No assets matched this search.<br /><br /></NoRecordsTemplate>
              <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true"
                  ShowExportToCsvButton="false" ShowExportToPdfButton="false" ShowAddNewRecordButton="false" />
              <Columns>
                  <telerik:GridTemplateColumn HeaderText="View" ItemStyle-HorizontalAlign="Center" >
                      <ItemTemplate >
                          <asp:ImageButton ID="ibtnView" runat="server" CommandName="View" ImageUrl="images/1258747021_old-edit-find.png" ToolTip="Drill down to view more detail"  />
                      </ItemTemplate>
                  </telerik:GridTemplateColumn>
                  <telerik:GridBoundColumn DataField="pct" HeaderText="% of Total" UniqueName="pct" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:p}"   />         
                  <telerik:GridBoundColumn DataField="cnt" HeaderText="Device Count" UniqueName="cnt" ItemStyle-HorizontalAlign="Right"   DataFormatString="{0:###,###,###}"  />
           
              </Columns>
          </MasterTableView>
      </telerik:RadGrid>

I don't think the ItemCommand code is useful here since when it is called, it works. 

Here is the code that creates the columns:

Sub BindColumns()
     
    dgDevices.Columns.Clear()
     
    Dim btncol As GridButtonColumn = New GridButtonColumn
    btncol.ButtonType = ButtonColumnType.LinkButton
    btncol.HeaderText = "View"
    btncol.CommandName = "View"
    btncol.Text = "<IMG src=""images/1258747021_old-edit-find.png"" border=0 /> "
    btncol.ItemStyle.HorizontalAlign = HorizontalAlign.Center
    dgDevices.Columns.Add(btncol)
     
    Dim bc As GridBoundColumn
     
    bc = New GridBoundColumn()
    bc.HeaderText = "Count"
    bc.SortExpression = "cnt"
    bc.DataField = "cnt"
    dgDevices.Columns.Add(bc)
 
    bc = New GridBoundColumn()
    bc.HeaderText = "Percent"
    bc.DataField = "pct"
    bc.DataFormatString = "{0:p}"
    dgDevices.Columns.Add(bc)
     
    Dim I As Integer
    For I = 0 To cblColumns.Items.Count - 1
        If cblColumns.Items(I).Selected Then
            Dim Value As String = cblColumns.Items(I).Value
            bc = New GridBoundColumn()
            bc.HeaderText = cblColumns.Items(I).Text
            bc.SortExpression = cblColumns.Items(I).Value
            bc.DataField = Value
            dgDevices.Columns.Add(bc)
        End If
    Next
End Sub

Here is the code that binds the data to the RadGrid - and it calls the above subroutine to add the columns

Sub BindDevices()
    Dim myConnection As SqlConnection = New SqlConnection(AppSettings.Get("connAccess2"))
    Dim dt As DataTable
    Dim myCommand As SqlDataAdapter
    Dim mySelectString As String
         
    mySelectString = " select * FROM ... "
        
    myCommand = New SqlDataAdapter(mySelectString, myConnection)
 
    dt = New DataTable()
 
    myCommand.Fill(dt)
  
    BindColumns()  'dynamically add the columns selected in the check box list
 
    dgDevices.DataSource = dt.DefaultView
        
End Sub

Thanks for any help.











Robert
Top achievements
Rank 1
 answered on 02 Oct 2017
4 answers
229 views

Legend order is reversed for some reason (see attached)

Any suggestions

David
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 02 Oct 2017
0 answers
39 views

Hi,

 

Is it possible to drag filenames from a fileexplorer to preferably a grid, or a treeview?

If so, can anyone guide me how to?

 

Kind regards

Andreas

Andreas
Top achievements
Rank 1
 asked on 02 Oct 2017
4 answers
239 views

I'm getting some very odd behavior on my radgrid when I call resizetofit after settings columns Display=false from the code behind. A lot of white space is left on the first call and on subsequent calls the grid continues to shrink and be set to more readable dimensions. The grid is very large (105 columns) and I'm using a checkbox list to allow users to select which columns they want visible which removes excess columns using radGrid.MasterTableView.Columns[i].Display = false; Currently I'm resolving the issue by wrapping the script called afterwards in a loop so it runs 3 times, but it continues to shrink long after even 3 calls. Depending on how many rows are removed it continues to shrink (at a reducing rate) up to 8 calls afterwards. Javascript and grid markup below:

<script>
            function resize() {
                var grid = $find("<%= gridAgents.ClientID %>");
                var columns = grid.get_masterTableView().get_columns();
                for (var i = 0; i < columns.length; i++) {
                    columns[i].resizeToFit();
                }
            }
</script>
 
<telerik:RadGrid ID="gridAgents" runat="server" AllowPaging="True" AllowSorting="True"
                    OnNeedDataSource="gridAgents_NeedDataSource" ShowGroupPanel="True"
                    OnEditCommand="gridAgents_EditCommand" OnUpdateCommand="gridAgents_UpdateCommand"
                    OnDeleteCommand="gridAgents_DeleteCommand" OnCancelCommand="gridAgents_CancelCommand"  
                           OnInsertCommand="gridAgents_InsertCommand" OnItemUpdated="gridAgents_ItemUpdated"
                    OnItemDeleted="gridAgents_ItemDeleted" OnItemInserted="gridAgents_ItemInserted"
                    AutoGenerateColumns="false">
                    <HeaderStyle BorderColor="LightGray" BorderWidth="1px" />
                    <GroupingSettings CollapseAllTooltip="Collapse all groups" />
                    <ClientSettings AllowDragToGroup="True">
                        <Resizing AllowColumnResize="true" ResizeGridOnColumnResize="true" AllowResizeToFit="true" />
                    </ClientSettings>
                    <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top">
                        <Columns>
                            <telerik:GridEditCommandColumn>
                            </telerik:GridEditCommandColumn>
                            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="Delete"                                                                       UniqueName="DeleteColumn" ConfirmText="Delete record?">
                            </telerik:GridButtonColumn>
                                      //103 Bound/Template columns
                        </Columns>
                    </MasterTableView>
</telerik:RadGrid>
Eyup
Telerik team
 answered on 02 Oct 2017
1 answer
94 views

Hi,

I have a web application which uses many RadGrid controllers on a single page. Is there any possibility to has a set of class to handle RadGrid properties? So that all RadGrid will able to inherit the properties and much easier for me do any changes to all RadGrid when needed.

Thanks.

Eyup
Telerik team
 answered on 02 Oct 2017
1 answer
48 views

Hi,

We are using Radscheduler control to display appointments. However we are facing a very strange problem.

When we are creating an appointment that is for multiple hours (11:00 Am to 14:00 PM) , then it does not display completely. It is rendered but behind the rows of hours. So it displays only from 11AM to 12PM then it is back to the scheduler control. i think there is some CSS issue or something else?

Please help me,

 

Regards,

Piyush

 

 

 

Vessy
Telerik team
 answered on 02 Oct 2017
1 answer
81 views

I am rewriting a web page which is a list of items - mostly for viewing with the ability to edit notes to each line - one of the columns is updatable, another a hyperlink, a third to reorder the data

is RadGrid the best control if most of the columns read only - and there will not be any inserts

Vessy
Telerik team
 answered on 02 Oct 2017
10 answers
267 views

Hello,

 

I just started working with the ImageManager in the Editor and have a few questions regarding the provided examples.

1. Can the ImageManager window be resize?

2. I believe FileExplorer is used inside ImageManager. When I try to resize the left side of the FileExplorer to make it bigger, the slider  on the right side goes over the right side of Image Manager. Can anything be done to fix this behavior?

3. Can the slider’s visibility be changed dynamically? If yes, then how?

4. In my application I would like to use a physical path in the ImageManager and not virtual. And partially I was able to do so. The problem I have with that is that when I select the file in the FileExplorer, I do not see the image on the Preview panel and there is no info on the Properties panel either. Am I missing something?

 

Thank you

Jasmin
Top achievements
Rank 1
 answered on 29 Sep 2017
0 answers
184 views

After downloading patched Telerik.Web.UI.dll to address the recent security vulnerability (version 2017.1.228.45), I'm running into this error:

Telerik.Web.UI.RadEditor with ID='[some control id]' was unable to find an embedded skin with the name 'Vista'. Please, make sure that the skin name is spelled correctly and that you have added a reference to the Telerik.Web.UI.Skins.dll assembly in your project. If you want to use a custom skin, set EnableEmbeddedSkins=false.

Is this because the version number of Telerik.Web.UI.Skins.dll no matches the version number of Telerik.Web.UI.dll?  Is there a practical way of addressing without upgrading all components to match

 

 

 

Matthew
Top achievements
Rank 1
 asked on 29 Sep 2017
0 answers
118 views
I have the following scenario:

- a main aspx page
- a user control inside that aspx.page, lets call this parent_user_control
- two RadComboBox, with only numbers on them. 
- The first one, RadComboBox1, for example when the user chooses 2, it will dynamically generate 2 user controls, lets call them child_user_control_1
- The second one, RadComboBox2, for example when the user chooses 1, it will dynamically generate 1 user control, lets call it child_user_control_2. 
- child_user_control_2, has another RadComboBox, called RadComboBox_2_1, again with numbers only, that dynamically generates another user control, called grandchild_user_control.
- grandchild_user_control has a RadComboBox called RadComboBox_grandchild, with an EmptyMessage="Please select", and only numbers, but the numbers must match RadComboBox1, as in, when 2 was chosen, only options 1 through 2 should appear in this RadComboBox_grandchild. If the value from RadComboBox1 changes to 5, then the range of values in RadComboBox_grandchild should change to 1 through 5. Same if it decreases from 2 to 1, only the value 1 should be available.
- I properly handled the recreation of dynamic user controls, so all values persist, and the values in RadComboBox_grandchild get properly updated. 

Here is the problem:

When I change the value to a smaller number, say from 3 to 1, and I have, for example, the value 2 already chosen in RadComboBox_grandchild, the list gets updated, and in the code_behind the values change correctly (as in selectedIndex is -1, selectedItem is null, etc.) BUT, I do not see "Please select", I still see the value "2", even though it is no longer in the list.

How can I avoid this? How can I make it show the EmptyMessage "Please select" again? I tried the ClearSelection method, but it didn't do anything, because it already is without a selection. It seems to me that the mechanism used to persist the values from the previous postback, is forcefully persisting a value that no longer exists.
Fermin
Top achievements
Rank 1
 asked on 29 Sep 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?