Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
99 views
Hi,
I have a treeview on my page and I have a clientside search on it.
My tree height is longer that the page, now if a node be found on bottom of page and I select it, now how can I scroll the page to appear the slected node
Princy
Top achievements
Rank 2
 answered on 10 Mar 2009
3 answers
207 views
Hello,


I encounter a strange problem when trying to apply different styles for different hierarchy levels on RadGrid.
I'm using the same approach as described in following article:
http://www.telerik.com/help/aspnet-ajax/grddifferentstylesineachhierarchylevelwithskin.html
All works fine for HeaderStyle, ItemStyle and AlternatingItemStyle. However as soon as I try to apply a new style to CommandItemStyle, RadGrid behaves in a weired way:
Applying style "OuterItemStyle" on the CommandItemStyle of the MasterTable works, but applying "InnerItemStyle" to the first DetailTable CommandItemStyle doesn't work at all.
Some snippets of my code:




<style type="text/css">
   .OuterItemStyle
   {
     background: #90979E !important;
     color: black !important;
     /*add more style definitions here*/
   }
  
   .........

   .InnerItemStyle
   {
     background: #E0E1E2 !important;
     color: black !important;
     /*add more style definitions here*/
   }
 
   }
</style>

.......

<telerik:RadGrid runat="server" .... >

<MasterTableView CommandItemDisplay="Top" ... >
    <ItemStyle CssClass="OuterItemStyle" />
    <CommandItemStyle CssClass="OuterItemStyle" />

   ...............

   <DetailTables>
    <telerik:GridTableView  CommandItemDisplay="Top".......>
        <ItemStyle CssClass="InnerItemStyle" />
            <CommandItemStyle CssClass="InnerItemStyle" />

........

When inspecting the source code of the generated page in the Dom-Inspector, I see that the "OuterItemStyle" css class has been applied to the CommandItem of the MasterTable but no class has been applied to the DetailTable.
It seems as if the line <CommandItemStyle CssClass="InnerItemStyle" /> isn't affecting any value...
Is this a problem of RadGrid or did I just missed a thing?

Any help is highly appreciated,

Thanks a lot

Dany
Dany Thielen
Top achievements
Rank 1
 answered on 10 Mar 2009
2 answers
223 views
I have a Grid (SubGrid1) within a Grid (RadGrid1).
When I edit SubGrid1 I need to load values for a RadComboBox.
I'm currently loading values for RadGrid1 without problems through the RadGrid_ItemDataBound event:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)     
{     
      if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))     
      {           
           //Loading RadComboBoxes here without problems     
           //...     
      }     
      //...       
}   

When I try to do the same for SubGrid1 I came to find out that the SubGrid1_ItemDataBound event is not being called upon selecting "Edit" on this grid.

<telerik:RadGrid ID="SubGrid1" runat="server" AllowSorting="False" GridLines="None" 
    Style="margin-left: 0px" AutoGenerateColumns="False" Width="95%" OnItemDataBound="SubGrid1_ItemDataBound" OnItemCommand="SubGrid1_ItemCommand" 
     OnItemDeleted="SubGrid1_ItemDeleted" OnItemCreated="SubGrid1_ItemCreated" 
    OnItemInserted="SubGrid1_ItemInserted" OnItemUpdated="SubGrid1_ItemUpdated">  
    <HeaderContextMenu EnableTheming="True">  
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
    </HeaderContextMenu> 
    <MasterTableView EditMode="InPlace" CommandItemSettings-AddNewRecordText="Add New Phone Number" 
        CommandItemDisplay="Top">  
        <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </RowIndicatorColumn> 
        <ExpandCollapseColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </ExpandCollapseColumn> 
        <Columns> 
            <telerik:GridEditCommandColumn HeaderStyle-Width="20px" EditText="Edit">  
                <HeaderStyle Width="20px"></HeaderStyle> 
            </telerik:GridEditCommandColumn> 
            <telerik:GridMaskedColumn Mask="(###) ###-####" 
             UniqueName="Phone" HeaderText="Phone#" DataField="Phone">  
             <HeaderStyle Width="120px" /> 
            </telerik:GridMaskedColumn> 
            <telerik:GridTemplateColumn HeaderStyle-Width="20px" UniqueName="colPhoneType">  
                <EditItemTemplate> 
                    <telerik:RadComboBox ID="PhoneType" runat="server">  
                    </telerik:RadComboBox> 
                </EditItemTemplate> 
            </telerik:GridTemplateColumn> 
            <telerik:GridTemplateColumn HeaderStyle-Width="20px" UniqueName="DeletePhoneColumn">  
                <HeaderStyle Width="20px"></HeaderStyle> 
                <ItemTemplate> 
                    <asp:ImageButton ID="imgbtnDelete" ToolTip="Delete Contact" runat="server" CommandName="Delete" ImageUrl="~/App_ThemesCustom/Pro1/images/recycle-bin-icon.gif" 
                    OnClientClick="javascript:if(!confirm('This action will delete the selected contact. Are you sure?')){return false;}" /> 
                 </ItemTemplate> 
            </telerik:GridTemplateColumn> 
        </Columns> 
        <EditFormSettings EditFormType="Template">  
            <FormStyle /> 
            <FormTemplate> 
                <asp:Table runat="server" ID="Table1" CellSpacing="1" CellPadding="1" Width="250" 
                    border="0">  
                    <asp:TableRow> 
                        <asp:TableCell></asp:TableCell> 
                        <asp:TableCell></asp:TableCell> 
                    </asp:TableRow> 
                    <asp:TableRow> 
                        <asp:TableCell> 
                            Phone Number:  
                        </asp:TableCell> 
                        <asp:TableCell> 
                            <telerik:RadTextBox ID="PhoneEdit" Text='<%# Bind( "Phone") %>' runat="server">  
                            </telerik:RadTextBox> 
                            <cc1:MaskedEditExtender ID="MaskPhoneEdit" runat="server" TargetControlID="PhoneEdit" MaskType="Number" Mask="(999) 999-9999" ClearMaskOnLostFocus="false">  
                            </cc1:MaskedEditExtender> 
                        </asp:TableCell> 
                    </asp:TableRow> 
                    <asp:TableRow> 
                        <asp:TableCell>                                                       
                            Phone Type:  
                        </asp:TableCell> 
                        <asp:TableCell ID="tblClPhoneType" runat="server" Wrap="False">  
                            <telerik:RadComboBox Width="150px" ID="RadComboPhoneType" runat="server">  
                                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                            </telerik:RadComboBox> 
                        </asp:TableCell> 
                    </asp:TableRow> 
                      
                </asp:Table> 
                <asp:Table runat="server" Style="width: 95%">  
                    <asp:TableRow> 
                        <asp:TableCell Style="text-align: right;" ColumnSpan="2">  
                            <asp:Button ID="Button1" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' 
                                runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>  
                            </asp:Button>&nbsp;  
                            <asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel">  
                            </asp:Button> 
                        </asp:TableCell> 
                    </asp:TableRow> 
                </asp:Table> 
            </FormTemplate> 
        </EditFormSettings> 
        <NoRecordsTemplate> 
            No Records Found  
        </NoRecordsTemplate> 
        <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </RowIndicatorColumn> 
        <ExpandCollapseColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </ExpandCollapseColumn> 
    </MasterTableView> 
    <ClientSettings AllowColumnsReorder="True" AllowRowsDragDrop="True" ReorderColumnsOnClient="True">  
        <Selecting AllowRowSelect="True" /> 
    </ClientSettings> 
    <FilterMenu EnableTheming="True">  
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
    </FilterMenu> 
</telerik:RadGrid> 

protected void RadGridPhones_ItemDataBound(object sender, GridItemEventArgs e)    
{  
     //This event is not firing.  

Can anybody see anything wrong with how I do it? I don't use DataSourceID, but there has got to be a way to get it to work this way too.

The only difference between RadGrid1 and SubGrid1 is that I do an InPlace edit on SubGrid1.

Thanks.



Stephan
Top achievements
Rank 1
 answered on 10 Mar 2009
2 answers
262 views
Hi,
in radnumerictextbox I set:   <NumberFormat KeepNotRoundedValue="True" /> and decimal digits = 2.
And now when I write: 12,1299 the controls shows 12,13.
I want that digits after 2 decimal digits will remove automatically .
How can I do that?
Daniel
Telerik team
 answered on 10 Mar 2009
1 answer
186 views
Hi All
 
I will try to keep this simple as possible.  
 
I have a data source that changes constantly.  It always contains two fields: JOB_ID, TABLE_NAME.  Then a number of extra fields will exist.  For example sometimes it will contain NAME, DOB.  Some other time it might contain FAVE_COLOUR, FAVE_HAT.
 
The datasource is taken from a dropdownlist that then updates the gird. 

So for example the data source could like this:
 
JOB_ID   TABLE_NAME   NAME,  DOB
 
or like this
 
JOB_ID   TABLE_NAME   FAVE_COLOUR    FAVE_HAT
 
or like 
 
JOB_ID   TABLE_NAME   X    Y   Z  ......so on....
 
So my grid is set to automatically generate columns.
 
I also need to place onto the grid inset, edit and delete buttons which has been successfully done.
 
I have successfully written code for the update, insert and delete commands.  So that is not an issue.
 
My remaining issue comes when I handle the auto generate Edit form which is used for both the Edit and Insert operations.  When someone wishes to insert a new record they need provide all the data but when they wish to edit they only need to provide the random columns and not the JOB_ID and TABLE_NAME.  
 
When you are inserting the user should be able to choose the JOB_ID and TABLE_NAME from a drop down list so I have used the grids dropdown GridDropDownColumn for both these fields.  Which is working fine.  But I do now get the columns twice as they are being specified at design and run time now by the auto generate feature.
 
When you are editing the user should not be able to choose a JOB_ID and TABLE_NAME as they form the primary key for the update.  So they need to be hidden or displayed and locked down.
 
It seems every approach I take something does not work.  For example one approach looks for and hides the repeated columns (JOB_ID, TABLE_NAME) and hides them but this only works when the grid contains data.  When there is no data the columns appear.  Also when I go to the edit form I disable the dropdown lists but I cannot tell between an update and an insert.  So it disables them for both!

I have included the grid and the events I am using to try and extract this funtionaility

Thanks for your help
 
  <telerik:RadComboBox ID="ddTables" runat="server" EnableEmbeddedSkins="false" Skin="LBCompanion_Blue" 
        AllowCustomText="true" MarkFirstMatch="true"
    </telerik:RadComboBox> 
    <br /> 
    <br /> 
 
    <telerik:RadGrid ID="dgResults" runat="server" EnableEmbeddedSkins="false" Skin="LBCompanion_Blue" 
        EnableLinqExpressions="False" OnNeedDataSource="dgResults_NeedDataSource" AllowFilteringByColumn="True" 
        AllowSorting="True" AllowPaging="True" PageSize="40" GridLines="None"
        <HeaderContextMenu EnableTheming="True"
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        </HeaderContextMenu> 
        <MasterTableView AutoGenerateColumns="True" CommandItemDisplay="Top" DataKeyNames="JOB_ID, TABLE_NAME"
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
            </ExpandCollapseColumn> 
            <Columns> 
                <telerik:GridDropDownColumn DataField="JOB_ID" HeaderText="JOB_ID" UniqueName="FIXED_JOB_ID" 
                    AutoPostBackOnFilter="true" ListTextField="ID" ListValueField="ID" DataSourceID="odsDataEvents" 
                    ItemStyle-Width="100" FilterControlWidth="100"
                </telerik:GridDropDownColumn> 
                <telerik:GridDropDownColumn DataField="TABLE_NAME" HeaderText="TABLE_NAME" UniqueName="FIXED_TABLE_NAME" 
                    AutoPostBackOnFilter="true" ListTextField="TABLE_NAME" ListValueField="TABLE_NAME" DataSourceID="odsTables" 
                    ItemStyle-Width="100" FilterControlWidth="100"
                </telerik:GridDropDownColumn> 
                <telerik:GridEditCommandColumn UniqueName="Edit"
                </telerik:GridEditCommandColumn> 
                <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete"
                </telerik:GridButtonColumn> 
            </Columns> 
            <EditFormSettings> 
                <EditColumn InsertText="Insert value" UpdateText="Update value" UniqueName="EditCommandColumn1" 
                    CancelText="Cancel edit"
                </EditColumn> 
            </EditFormSettings> 
        </MasterTableView> 
        <FilterMenu EnableTheming="True"
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        </FilterMenu> 
        <ClientSettings> 
            <Scrolling AllowScroll="True" ScrollHeight="400" UseStaticHeaders="True" SaveScrollPosition="True"
            </Scrolling> 
        </ClientSettings> 
    </telerik:RadGrid> 

 void dgResults_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
 
            if (e.Item.ItemType == GridItemType.EditFormItem) 
            { 
 
                GridEditableItem eeditedItem = e.Item as GridEditableItem; 
 
                editedItem["FIXED_JOB_ID"].Enabled = false
                editedItem["FIXED_TABLE_NAME"].Enabled = false
            } 
        }  
    } 
 
 void dgResults_PreRender(object sender, EventArgs e) 
    { 
 
 
 
 
        foreach (GridDataItem dataItem in dgResults.MasterTableView.Items) 
        { 
            foreach (GridColumn column in dgResults.MasterTableView.RenderColumns) 
            { 
                if (column is GridBoundColumn) 
                { 
 
                    if (column.UniqueName == "JOB_ID" || column.UniqueName == "TABLE_NAME") 
                    { 
                        GridBoundColumn bcol = (GridBoundColumn)column; 
                        bcol.ReadOnly = true
                        bcol.Visible = false
                    } 
                } 
            } 
        } 
 
 
        GridColumnCollection cols = dgResults.MasterTableView.Columns; 
        GridColumn colo = cols.FindByUniqueName("Edit"); 
 
        colo.OrderIndex = 0
 
        colo = cols.FindByUniqueName("Delete"); 
 
        colo.OrderIndex = 1
 
 
 
    } 
 
 

 
Georgi Krustev
Telerik team
 answered on 10 Mar 2009
2 answers
144 views
Hello, I have a parent grid with two detail grids on the same level inside the parent. I have set up where you can reorder rows by dragging and dropping based on the demo. But, I am only interested in allowing one of the detail grids to have this functionality. All I want is to allow child grid 1 to be reordered. The parent and the other child do not need any functionailty. I can't seem to figure out how to not allow the drag and drop for the others. Thanks
Henry Derstine
Top achievements
Rank 1
 answered on 10 Mar 2009
2 answers
79 views
I created a grid using the code below.  The page loads fine and the first "next page" works.  But after that the "page"  links/buttons no longer work.  Any thoughts would be appreciated.

 

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Dim PlaceHolder1 As PlaceHolder
        Dim RadGrid1 As RadGrid = New RadGrid
        Dim sql As String = "SELECT [ProductName] From Products order by ProductName"
        Dim GridDataSet As DataSet = CDSSQLFunctions.GetDataSet(sql)
        Dim boundColumn As GridBoundColumn
        RadGrid1.Skin = "Default"
        RadGrid1.Width = Unit.Percentage(100)
        RadGrid1.PageSize = 5
        RadGrid1.AllowPaging = True
        RadGrid1.AutoGenerateColumns = False
        RadGrid1.GroupingEnabled = True
        RadGrid1.ShowGroupPanel = True
        RadGrid1.MasterTableView.PageSize = 15

        BoundColumn = New GridBoundColumn
        boundColumn.DataField = "ProductName"
        boundColumn.HeaderText = "ProductName"
        RadGrid1.MasterTableView.Columns.Add(boundColumn)
        RadGrid1.DataSource = GridDataSet
        RadGrid1.DataBind()
        PlaceHolder1 = phGrid  '     <asp:PlaceHolder ID="phGrid" runat="server"></asp:PlaceHolder><br />
        PlaceHolder1.Controls.Add(RadGrid1)

    End Sub

Bruce
Top achievements
Rank 1
 answered on 10 Mar 2009
1 answer
139 views
 Hi,

           I'm using RAD Outlook grid in my sample application. I would like to show total number of records under each category for example, Received : Prabhu (4)
            
Which means, I received 4 mails from Prabhu. Is it possible in Telerik outlook grid??? If so how???

Thanks in Advance,
Prabhu
Shinu
Top achievements
Rank 2
 answered on 10 Mar 2009
1 answer
67 views
I followed an example but it seems to delete the record but when i go to access database the record was not deleted why ?

Here is my code:

Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource 
 
        Dim strCaminho As String = Server.MapPath("~/adm/bd/observatorio.mdb") 
        Dim MyOleDbConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strCaminho & ";") 
        Dim MyOleDbDataAdapter As New OleDbDataAdapter 
        MyOleDbDataAdapter.SelectCommand = New OleDbCommand("Select distinct news_id,news_titulo,news_dtinclusao from tblNoticias order by news_dtinclusao desc", MyOleDbConnection) 
        Dim myDataTable As DataTable 
 
        If Not (Session("DataSource") Is Nothing) Then 
            myDataTable = CType(Session("DataSource"), DataTable) 
        Else 
            Try 
                myDataTable = New DataTable 
                MyOleDbConnection.Open() 
 
                Try 
                    MyOleDbDataAdapter.Fill(myDataTable) 
                Catch ex As Exception 
                    Me.lblError.Text = "Ocorreu um erro na tentativa de carregar os dados !" 
                    'Me.lblError.Text = ex.Message 
                    Exit Sub 
                Finally 
                    MyOleDbConnection.Close() 
                End Try 
 
            Catch ex As Exception 
                Me.lblError.Text = "Não foi possível abrir o banco de dados" 
                'Me.lblError.Text = ex.Message 
                Exit Sub 
            End Try 
            myDataTable.PrimaryKey = New DataColumn() {myDataTable.Columns("news_id")} 
            Session("DataSource") = myDataTable 
        End If 
        RadGrid1.DataSource = myDataTable 
    End Sub 
 
 
    Protected Sub RadGrid1_DeleteCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) 
        Dim table As DataTable = CType(Session("DataSource"), DataTable) 
        Dim ID As String = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("news_id").ToString() 
        If Not (table.Rows.Find(ID) Is Nothing) Then 
            table.Rows.Find(ID).Delete() 
            table.AcceptChanges() 
            Session("DataSource") = table 
        End If 
    End Sub 

Yavor
Telerik team
 answered on 10 Mar 2009
1 answer
140 views
I am doing a delete of a row on client side. I have an oncommand set up so that if the delete button is clicked, I first want to pop up a rad window giving the user a choice of what type of delete they wish to do.

In the oncommand client side, how do I know what row the user has clicked on the delete icon? I do not have client row selected set.

Thanks,
Laura
Shinu
Top achievements
Rank 2
 answered on 10 Mar 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?