Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
131 views
Hi,
I have a grid in an editform of another grid. The datasource of the second grid is dependant on a datakeyvalue of the first grid. How do i do this in the NeedDataSource event of the second grid?
If I try and use the SelectedIndex I get nothing as first gris is in edit mode.
I am looking for something like below but unfortunately the row is not selected, just inedit mode:
Protected Sub UserNeedDatasource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs)
Dim DataKey As String = Me.Grid1.MasterTableView.DataKeyValues(Me.Grid1SelectedIndexes(0))("DataKeyName").ToString
Me.Grid2.DataSource = MyDataSource.GetData(DataKey)
end Sub

Any ideas?
Roger
Top achievements
Rank 1
 answered on 06 Dec 2012
6 answers
1.2K+ views
I want to know a way I can reload the RadGrid with the DataSource that it is originally loading from. Case Scenario would involve the user click on a button to refresh the RadGrid to return the original data from the database, because they don't want the updated changes on the RadGrid anymore. I've tried DataBind, but it does not do anything for me. Is there an event that I need to use to do what I need it to do?
I am using .ASPX and C#. Thanks in advanced.

 

protected void RadGrid1_Load(object source, GridNeedDataSourceEventArgs e)
{
    String ConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    SqlConnection conn = new SqlConnection(ConnString);
    SqlDataAdapter adapter = new SqlDataAdapter();
    adapter.SelectCommand = new SqlCommand(@"SELECT columns FROM tables)", conn);
    DataSet myDataTable = new DataSet();
    conn.Open();
    try
    {
        adapter.Fill(myDataTable, "tables");
    }
    finally
    {
        conn.Close();
    }
    DataView myDataView = myDataTable.Tables["tabels"].DefaultView;
    RadGrid1.MasterTableView.DataSource = myDataView;
    RadGrid1.MasterTableView.DataBind();
}
Nancy
Top achievements
Rank 1
 answered on 06 Dec 2012
16 answers
225 views
Hi, I have a very annoying problem with my comboboxes that occurs not everytime but i would say ~5% of the time, testing on IE8 and FF 14.0.1. My scenario (using Q2 2012):

Im having 2 related comboboxes in a RadAjaxPanel which are filled once from a database. Each combobox filters each other since the first one contains the parents of the second. Im using server-side coding to do the filtering (by using item visibility, based on Parent (Attribute) property).

95%, everthing works like it should but i noticed that sometimes the filtering does not occur (selecting an element in the first combobox doesnt filter the second one at all...it visible items stays like there were). I though first that the postback was not occuring on those times but after investigation, it is (OnSelectedIndexChanged gets called and item visibility is set correctly for all items). It's just the displaying that dont get refreshed somehow. The only way I can do something is selecting something else in the first combobox and reselecting the one i really wanted (to force an index change)...then it filters.

I initially had AutoPostBack=True on both comboboxes and tried to put them to false and handle it on client-side (OnClientSelectedIndexChanged), like someone did on a forums. Problem still occuring ...but seems like less often so i kept it like that.

Here's a trimmed down version of my code:

aspx
<telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server">
               <div class="EnterpriseNodes1">
                    <telerik:RadComboBox ID="RadComboBox1" runat="server" Skin="WebBlue" MarkFirstMatch="true" Visible="false" AllowCustomText="true" Filter="StartsWith" CssClass="combo1" NoWrap="True" OnItemDataBound="RadComboBox1_ItemDataBound" AutoPostBack="false" OnSelectedIndexChanged="RadComboBox1_OnSelectedIndexChanged" OnClientSelectedIndexChanged="RadComboBox1_OnClientSelectedIndexChanged">
                    </telerik:RadComboBox>
                    <br />
                    <telerik:RadComboBox ID="RadComboBox2" runat="server" Skin="WebBlue" MarkFirstMatch="true" Visible="false" AllowCustomText="true" Filter="StartsWith" CssClass="combo2" NoWrap="True" OnItemDataBound="RadComboBox2_ItemDataBound" AutoPostBack="false" OnSelectedIndexChanged="RadComboBox2_OnSelectedIndexChanged" OnClientSelectedIndexChanged="RadComboBox2_OnClientSelectedIndexChanged">
                    </telerik:RadComboBox>
                    <br />
    </div>
</telerik:RadAjaxPanel>

js
function RadComboBox1_OnClientSelectedIndexChanged(sender, args) {
    __doPostBack('RadComboBox1', '');
}
 
function RadComboBox2_OnClientSelectedIndexChanged(sender, args) {
    __doPostBack('RadComboBox2', '');
}

cs
protected void Page_Load(object sender, EventArgs e)
    {
 
        if (!IsPostBack)
        {
             RadComboBoxItem item = null;
 
            item = new RadComboBoxItem();
            item.Value = "1";
            item.Text = "Canada";
 
            RadComboBox1.Items.Add(item);
 
            item = new RadComboBoxItem();
            item.Value = "2";
            item.Text = "USA";
 
            RadComboBox1.Items.Add(item);
 
            item = new RadComboBoxItem();
            item.Value = "3";
            item.Text = "BC";
 
            RadComboBox2.Items.Add(item);
 
            item = new RadComboBoxItem();
            item.Value = "4";
            item.Text = "NB";
 
            RadComboBox2.Items.Add(item);
 
            item = new RadComboBoxItem();
            item.Value = "5";
            item.Text = "ON";
 
            RadComboBox2.Items.Add(item);
 
            item = new RadComboBoxItem();
            item.Value = "6";
            item.Text = "CAL";
 
            RadComboBox2.Items.Add(item);
 
            item = new RadComboBoxItem();
            item.Value = "7";
            item.Text = "FLA";
 
            RadComboBox2.Items.Add(item);
 
            item = new RadComboBoxItem();
            item.Value = "8";
            item.Text = "NY";
 
            RadComboBox2.Items.Add(item);
 
 
            RadComboBox1.Text = "";
            RadComboBox1.ClearSelection();
            RadComboBox1.Visible = true;
 
            RadComboBox2.Text = "";
            RadComboBox2.ClearSelection();
            RadComboBox2.Visible = true;
        }
 
     }

protected void RadComboBox1_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {  
 
        FilterNext(ref RadComboBox1, ref RadComboBox2);
        
    }
 
private void FilterNext(ref RadComboBox cbCurrent, ref RadComboBox cbNext)
     {
         if (cbCurrent.Text == "Canada")
         {
             for (int i = 0; i <= cbNext.Items.Count - 1; i++)
             {
                 if (cbNext.Items[i].Text == "BC" || cbNext.Items[i].Text == "NB" || cbNext.Items[i].Text == "ON")
                 {
                     cbNext.Items[i].Visible = true;
                     //WriteLog("true " + cbNext.Items[i].Text);
                 }
                 else
                 {
                     cbNext.Items[i].Visible = false;
                     //WriteLog("false " + cbNext.Items[i].Text);
 
                 }
             }
         }
 
         if (cbCurrent.Text == "USA")
         {
             for (int i = 0; i <= cbNext.Items.Count - 1; i++)
             {
                 if (cbNext.Items[i].Text == "CAL" || cbNext.Items[i].Text == "FLA" || cbNext.Items[i].Text == "NY")
                 {
                     cbNext.Items[i].Visible = true;
                     //WriteLog("true " + cbNext.Items[i].Text);
                 }
                 else
                 {
                     cbNext.Items[i].Visible = false;
                     //WriteLog("false " + cbNext.Items[i].Text);
                 }
             }
         }
 
         cbNext.DataBind();
     }

For those who want to test it out...please spend time on selection changing.. I usually need  to spend like 2-3min to making it fail.

Please help and TIA
Martin Roussel
Top achievements
Rank 1
 answered on 06 Dec 2012
5 answers
156 views
The PivotGrid looks like a very useful tool. We've been doing this kind of thing by hand all the time for our clients, and it would be great to simplify it! There are a few things that would be nice to see.

Cell Alignment: The ability to control the alignment of cells. Numeric values are typically right-aligned, but there doesn't seem to be a way to control the alignment. We haven't experimented with applying CSS styles; it may be possible with that, but should be right in the structure of the tool.

Export: Having the ability to export to Excel or PDF would be very useful.

Fields Window; When we design forms with any kind of filtering options, the filtering items are usually grouped at the top with the data showing below. There isn't any layout that really suits this approach however; a layout that is wide but not very high would be ideal.
Derek
Top achievements
Rank 1
 answered on 06 Dec 2012
0 answers
64 views
Hi

I need help with RadTabStrip. I have 4 tabs...Tab 1, Tab 2, Tab 3 and Tab4. By default the users see Tab 1. Once the user changes the Tab 1 to any other tab...I need to save the data from the 1st tab in database. 

If the users click Tab 3. If Tab 2 is missing information I need to redirect the user to Tab 2. 

Currently I am using TabClick Event to save the data in database if the user is coming from Tab 1..it also save some info for Tab 2. If Tab 2 is missing some information I display javascript alert and SetActiveTab  (i.e; ...set_selectedIndex(2) to 2...but the problem is I get redirected to Tab 3 first and then to Tab 2....how can i cancel Tab 3 redirect using server side code.

Jinisha
Jinisha
Top achievements
Rank 1
 asked on 06 Dec 2012
3 answers
83 views
hi,
how to hide columns by uisng ColumnElement?

Thanks & Regards
Anzar.M
Kostadin
Telerik team
 answered on 06 Dec 2012
4 answers
1.7K+ views
Hi,

I use a dynamically created RadGrid which means the column unique names are not always the same. I perform some data modification on ItemDataBound based on a columns unique name which works as expected if the column exists.
    protected void grvReport_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = ((GridDataItem)e.Item); 
            item["coltrainerList"].Text = item["coltrainerList"].Text.Replace(",", "<br/>"); 
        } 
        // Other unrelated stuff 
    } 

Of course, if the column does not exist I get an error alert "Cannot find a cell bound to column name 'coltrainerList'". I expected this also - but I am unsure of how to determine if it exists or not. I tried the following:
if (item["coltrainerList"] != null) item["coltrainerList"].Text = item["coltrainerList"].Text.Replace(",", "<br/>"); 




Unfortunately, I still get the error alert. I have looked through the GridDataItem functions and not found one that can check if a unique column name exists in order to avoid this error.

Have I missed something?

Cheers.
Bertha
Top achievements
Rank 1
 answered on 06 Dec 2012
4 answers
75 views
Hello Team;


I always send prospects to Telerik site to look at the products so they'll purchase their own license for our development. I've heard that people like the very top menu item "Product Families" the way the arrow shows and the animation and how it appears. I would like to ask the team if there is a sample to show how we can accomplish this type of menu that is more engaging.

Thanks!
..Ben
Ben Hayat
Top achievements
Rank 2
 answered on 06 Dec 2012
3 answers
338 views
What is the recommended approach to converting the contents of a Grid cell to Proper Case using the vb.net command strConvert( <string> , VbStrConv.ProperCase)? Is it possible to do this in the code-behind page? In this case the column is GridBoundColumn.

Thanks,
Dave
Dave
Top achievements
Rank 1
 answered on 06 Dec 2012
1 answer
168 views
I am recently implementing the RadGrid to show the Payment Bills , together with "DetailTable" to show details of the Payment Bill such as Items Bought , Quantity, Price and Discount .
When I collapse the detailTables, the command button in the "DetailTable" does not close. Would you please tell me whether there exist   the javascript statement to detect expand/collapse of the "DetailTable" ? How to detect the changes and apply to the attribute "visible" in order to achieve this?

The following is my code : 
<telerik:RadGrid ID="grdPayment" runat="server" AutoGenerateColumns="false" HeaderStyle-Font-Bold="true"
                            AllowMultiRowSelection="true" AllowAutomaticInserts="True" OnDetailTableDataBind="
grdPayment_DetailTableDataBind"
 
                            CssClass="RadGridCustomClass" OnNeedDataSource="
grdPayment_NeedDataSource" Width="98%">
 
 
                            <MasterTableView HierarchyLoadMode="Client"   AllowSorting="true" NoDetailRecordsText=""
                                CommandItemDisplay="TopAndBottom" EditMode="InPlace" DataKeyNames="PaymentItemID">
                                <CommandItemTemplate>
                                    <div style="padding: 5px 5px;">
                                        <telerik:RadButton ID="btnInsert" runat="server" CommandName="InitInsert" Visible='<%# !
grdHAGroup.
 
MasterTableView.IsItemInserted %>'
                                            Text="Add new">
                                            <Icon PrimaryIconUrl="~/Image/Button/add.gif" PrimaryIconLeft="4" PrimaryIconTop="4" />
                                        </telerik:RadButton>
                                           
                                        <telerik:RadButton runat="server" Text="Save" ID="Button01" Visible='<%# !grdPayment.MasterTableView.IsItemInserted %>'>
                                            <Icon PrimaryIconUrl="~/Image/Button/save.gif" PrimaryIconLeft="8" PrimaryIconTop="4" />
                                        </telerik:RadButton>
                                           
                                        <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" Visible='<%#
grdPayment.EditIndexes.Count > 0 || grdPayment.MasterTableView.IsItemInserted %>'>
 
                                                            <img style="border:0px;vertical-align:middle;" alt="" src="~/Image/Button/cancel.gif" />Cancel editing
                                        </asp:LinkButton>  
                                        <asp:LinkButton ID="LinkButton3" runat="server" CommandName="PerformInsert" Visible='<%# grdPayment.MasterTableView.IsItemInserted %>'>
                                                            <img style="border:0px;vertical-align:middle;" alt="" src="~/Image/Button/yes.gif" /> Add this Bill No
                                        </asp:LinkButton>  
                                        <telerik:RadButton runat="server" Text="Delete selected Bill No(s)" ID="RadButton5"
                                            Visible='<%# !grdPayment.MasterTableView.IsItemInserted %>' OnClientClick="javascript:return confirm('Delete all selected customers?')"
                                            CommandName="DeleteSelected">
                                            <Icon PrimaryIconUrl="~/Image/Button/remove.gif" PrimaryIconLeft="8" PrimaryIconTop="4" />
                                        </telerik:RadButton>
                                           
                                    </div>
                                </CommandItemTemplate>
                                <Columns>
                                    <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
                                    <telerik:GridTemplateColumn UniqueName="CostCentreDisplyID" HeaderText="Bill No.">
                                        <ItemTemplate>
                                            <asp:Label ID="lblCostCentreID" runat="server" Text='<%# Eval("BillNo") %>' />
                                            <asp:TextBox ID="txtCostCentreID" runat="server" Text='<%# Bind("BillNo") %>' Width="95%"
                                                Style="display: none" />
                                        </ItemTemplate>
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="txtCostCentreID" runat="server" Width="95%" />
                                        </InsertItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn UniqueName="CostCentre" HeaderText="Description">
                                        <ItemTemplate>
                                            <asp:Label ID="lblCostCentre" runat="server" Text='<%# Eval("BillDesp") %>' />
                                            <asp:TextBox ID="txtCostCentre" runat="server" Text='<%# Bind("BillDesp") %>' Width="95%"
                                                Style="display: none" />
                                        </ItemTemplate>
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="txtCostCentre" runat="server" Width="95%" />
                                        </InsertItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    
                                    <telerik:GridBoundColumn DataField="discount" HeaderText="Discount(%)" DataFormatString="{0:###,##0.###0}"
                                        UniqueName="discount">
                                        <ItemStyle HorizontalAlign="Right" />
                                        <HeaderStyle HorizontalAlign="Right" />
                                        <ItemStyle Width="50px" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Amount" HeaderText="Certified Amount" DataFormatString="{0:###,##0.#0}"
                                        UniqueName="Amount">
                                        <ItemStyle HorizontalAlign="Right" />
                                        <HeaderStyle HorizontalAlign="Right" />
                                    </telerik:GridBoundColumn>
                                </Columns>
                                <DetailTables>
                                    <telerik:GridTableView DataKeyNames="PaymentItemID" Name="ItemLevel" Width="100%"
                                        CommandItemDisplay="TopAndBottom" EditMode="InPlace" HierarchyLoadMode="ServerOnDemand">
                                        <HeaderStyle CssClass="MostInnerHeaderStyle" />
                                        <CommandItemTemplate>
                                            <div style="padding: 5px 5px;">
                                              <telerik:RadButton ID="btnInsertDetail"
                                              runat="server" CommandName="InitDetailInsert"
                                                    Visible='<%#  !(Container as GridCommandItem).OwnerTableView.IsItemInserted %>' 
                                        Text="Add New Milestone#" >
                                            <Icon PrimaryIconUrl="~/Image/Button/add.gif" PrimaryIconLeft="4" PrimaryIconTop="4" />
                                            </telerik:RadButton>  
                                              <telerik:RadButton ID="btnCancelDetail"
                                              runat="server" CommandName="InitDetailCancel"
                                                  Visible='<%# grdPayment.EditIndexes.Count > 0 || (Container as GridCommandItem).OwnerTableView.IsItemInserted %>'
                                        Text="Cancel editing" >
                                            <Icon PrimaryIconUrl="~/Image/Button/cancel.gif" PrimaryIconLeft="4" PrimaryIconTop="4" />
                                            </telerik:RadButton>  
                                              <telerik:RadButton ID="btnPerformInsertNewDetail"
                                              runat="server" CommandName="PerformInsertDetail"
                                             Visible='<%# (Container as GridCommandItem).OwnerTableView.IsItemInserted %>'
                                        Text="Add this Record" >
                                            <Icon PrimaryIconUrl="~/Image/Button/add.gif" PrimaryIconLeft="4" PrimaryIconTop="4" />
                                            </telerik:RadButton>  
                                              <telerik:RadButton ID="btnDeleteDetails"
                                              runat="server" CommandName="InitDetailDelete"
                                                    OnClientClick="javascript:return confirm('Delete all selected customers?')"
                                                    Visible='<%#  !(Container as GridCommandItem).OwnerTableView.IsItemInserted %>'
                                        Text="Delete selected Milestone#" >
                                            <Icon PrimaryIconUrl="~/Image/Button/remove.gif" PrimaryIconLeft="4" PrimaryIconTop="4" />
                                            </telerik:RadButton>  
                                               
                                 
                                            </div>
                                        </CommandItemTemplate>
                                        <Columns>
                                            <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">
                                                <HeaderStyle Width="5%" />
                                                <ItemStyle Width="5%" />
                                            </telerik:GridClientSelectColumn>
                                            <telerik:GridTemplateColumn UniqueName="ItemNo" HeaderText="Item No.">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblMilestoneDisplyID" runat="server" Text='<%# Bind("ItemNo") %>' />
                                                    <asp:TextBox ID="txtMilestoneDisplyID" runat="server" Text='<%# Bind("ItemNo") %>'
                                                        Width="95%" Style="display: none" />
                                                </ItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="txtMilestoneDisplyID" runat="server" Width="95%" />
                                                </InsertItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn UniqueName="ItemDesp" HeaderText="Description">
                                                <ItemTemplate>
                          
                                                    <asp:TextBox ID="tbxCostActivities" runat="server" Text='<%# Bind("ItemDesp") %>'
                                                        Width="95%" Style="display: none" />
                                                </ItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="txtCostActivities" runat="server" Width="95%" />
                                                </InsertItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridBoundColumn DataField="Amount" HeaderText="Certified Amount" DataFormatString="{0:###,##0.#0}"
                                                UniqueName="Amount">
                                                <ItemStyle HorizontalAlign="Right" />
                                                <HeaderStyle HorizontalAlign="Right" />
                                            </telerik:GridBoundColumn>
                                        </Columns>
                                        <ExpandCollapseColumn Visible="True"/>
                                    </telerik:GridTableView>
                                </DetailTables>
                            </MasterTableView>
                            <ClientSettings AllowExpandCollapse="false">
                                <Selecting AllowRowSelect="true" />
                               </ClientSettings>
                        </telerik:RadGrid>

Vasil
Telerik team
 answered on 06 Dec 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
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?