Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
290 views

hi

using the web service  binding the child grid   on expanding event  of the js .when you expand the one row it is working ,if we expand all rows using the js only lost row is showing the data.

i downloaded the one sample from the forums and modified here is the code

<script runat="server">

    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridHeaderItem)
        {
            GridHeaderItem hitem = (GridHeaderItem)e.Item;
            CheckBox chk = new CheckBox();
            chk.Attributes["onclick"] = "javascript: ExpandCollapseAllTables()";
            hitem["ExpandColumn"].Controls.Add(chk);
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Two level hierarchy</title>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

        <script type="text/javascript" src="Script1.js"></script>

        <script type="text/javascript">
            function pageLoad(sender, args) {
                tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();

                commandName = "Load"

                WebService.GetCustomers(0, tableView.get_pageSize(),
                    tableView.get_sortExpressions().toString(), tableView.get_filterExpressions().toDynamicLinq(),
                        updateGrid);
            }
            function ExpandCollapseAllTables() {

                for (masterIndex = 0; masterIndex < 2; masterIndex++) {

                    var firstMasterTableViewRow = $find("<%= RadGrid1.MasterTableView.ClientID %>").get_dataItems()[masterIndex];
                    if (firstMasterTableViewRow.get_expanded()) {
                        firstMasterTableViewRow.set_expanded(false);
                    }
                    else {
                        firstMasterTableViewRow.set_expanded(true);
                    }
                }
          
            }
        </script>

    </telerik:RadCodeBlock>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Services>
                <asp:ServiceReference Path="~/WebService.asmx" />
            </Services>
        </telerik:RadScriptManager>
        <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
        <telerik:RadGrid ID="RadGrid1" AllowFilteringByColumn="true" Skin="Telerik" runat="server"
            GridLines="None" AllowPaging="true" AllowSorting="true"
            onitemcreated="RadGrid1_ItemCreated">
            <ClientSettings>
                <ClientEvents OnCommand="RadGrid1_Command" OnHierarchyExpanding="RadGrid1_HierarchyExpanding" />
            </ClientSettings>
            <MasterTableView HierarchyLoadMode="Client" ClientDataKeyNames="CustomerID">
                <Columns>
                    <telerik:GridBoundColumn SortExpression="CustomerID" DataField="CustomerID" HeaderText="CustomerID" />
                    <telerik:GridBoundColumn SortExpression="CompanyName" DataField="CompanyName" HeaderText="CompanyName" />
                    <telerik:GridBoundColumn SortExpression="ContactName" DataField="ContactName" HeaderText="ContactName" />
                    <telerik:GridBoundColumn SortExpression="ContactTitle" DataField="ContactTitle" HeaderText="ContactTitle" />
                    <telerik:GridBoundColumn SortExpression="Country" DataField="Country" HeaderText="Country" />
                    <telerik:GridBoundColumn SortExpression="City" DataField="City" HeaderText="City" />
                </Columns>
                <NestedViewTemplate>
                </NestedViewTemplate>
            </MasterTableView>
            <PagerStyle AlwaysVisible="true" />
        </telerik:RadGrid>
        <asp:Panel ID="Panel1" style="display:none;" runat="server">
            <telerik:RadGrid ID="RadGrid2" AllowFilteringByColumn="true" Skin="Telerik" runat="server"
                GridLines="None" AllowPaging="true" AllowSorting="true">
                <ClientSettings>
                    <ClientEvents OnCommand="RadGrid2_Command" />
                </ClientSettings>
                <MasterTableView ClientDataKeyNames="OrderID">
                    <Columns>
                        <telerik:GridBoundColumn SortExpression="OrderID" DataField="OrderID" HeaderText="OrderID"
                            DataType="System.Int32" />
                        <telerik:GridBoundColumn SortExpression="OrderDate" DataField="OrderDate" HeaderText="OrderDate"
                            DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}" />
                        <telerik:GridBoundColumn SortExpression="ShipName" DataField="ShipName" HeaderText="ShipName" />
                        <telerik:GridBoundColumn SortExpression="ShipCity" DataField="ShipCity" HeaderText="ShipdgdfgdCity" />
                        <telerik:GridBoundColumn SortExpression="ShipCountry" DataField="ShipCountry" HeaderText="ShipCountry" />
                    </Columns>
                </MasterTableView>
                <PagerStyle AlwaysVisible="true" />
            </telerik:RadGrid>
        </asp:Panel>
    </div>
    </form>
</body>
</html>

script1.js

var commandName = "";
var tableView = null;
var ordersView = null;
var ordersCommandName = "";

function RadGrid1_Command(sender, args) {
    args.set_cancel(true);

    collapseItems(sender);
  
    commandName = args.get_commandName();

    WebService.GetCustomers(tableView.get_currentPageIndex() * tableView.get_pageSize(), tableView.get_pageSize(),
                    tableView.get_sortExpressions().toString(), tableView.get_filterExpressions().toDynamicLinq(),
                        updateGrid);
}

function updateGrid(result) {
    tableView.set_dataSource(result);
    tableView.dataBind();

    var dataItems = tableView.get_dataItems();

    if (commandName == "Filter" || commandName == "Load") {
        WebService.GetCustomersCount(updateVirtualItemCount);
    }
}

function updateVirtualItemCount(result) {
    tableView.set_virtualItemCount(result);
}

function collapseItems(sender) {
    var dataItems = sender.get_masterTableView().get_dataItems();
    for (var i = 0, length = dataItems.length; i < length; i++) {
        var input = dataItems[i].get_element().cells[0].getElementsByTagName("input")[0];
        if (input.className == "rgCollapse") {
            input.click();
        }
    }
}

function RadGrid1_HierarchyExpanding(sender, args) {
    collapseItems(sender);

    var customerID = args.getDataKeyValue("CustomerID");
    var nestedViewItem = args.get_nestedViewItem();

    nestedViewItem.cells[1].appendChild($get("RadGrid2"));

    ordersView = $find("RadGrid2").get_masterTableView();

    ordersCommandName = "Load";

    WebService.GetOrdersByCustomerID(customerID, ordersView.get_currentPageIndex() * ordersView.get_pageSize(), ordersView.get_pageSize(),
                    ordersView.get_sortExpressions().toString(), ordersView.get_filterExpressions().toDynamicLinq(),
                        updateOrdersGrid);
}

function updateOrdersGrid(result) {
    ordersView.set_dataSource(result);
    ordersView.dataBind();

    if (ordersCommandName == "Filter" || ordersCommandName == "Load") {
        WebService.GetOrdersByCustomerIDCount(updateOrdersVirtualItemCount);
    }
}

function updateOrdersVirtualItemCount(result) {
    ordersView.set_virtualItemCount(result);
}

function RadGrid2_Command(sender, args) {
    ordersView = sender.get_masterTableView();
    var nestedViewItem = sender.get_element().parentNode.parentNode;
    var parentGridDataItem = $find(Telerik.Web.UI.Grid.GetNodePreviousSiblingByTagName(nestedViewItem, "tr").id);
    var customerID = parentGridDataItem.getDataKeyValue("CustomerID");

    args.set_cancel(true);

    ordersCommandName = args.get_commandName();

    WebService.GetOrdersByCustomerID(customerID, ordersView.get_currentPageIndex() * ordersView.get_pageSize(), ordersView.get_pageSize(),
                    ordersView.get_sortExpressions().toString(), ordersView.get_filterExpressions().toDynamicLinq(),
                        updateOrdersGrid);
}

please help me

downloaded sample file name is 102839_website

thanks and Regards
Srikanth.Narala

Yavor
Telerik team
 answered on 24 May 2010
1 answer
115 views
HI All,
i am intending to use object data source for a grid below you will find the the snippet of the object i intend calling 
using System; 
using System.Data; 
using System.Configuration; 
using MySql.Data.MySqlClient; 
using Microsoft.ApplicationBlocks.Data; 
 
 
 
/// <summary> 
/// Summary description for CommonDataProvider 
/// </summary> 
namespace com.myclass.DAL 
{ 
    public class CommonDataProvider 
    { 
        
 
        public static DataTable getDlr() 
        { 
            DataTable ds= null; 
            string str = ConfigurationManager.AppSettings["emgConnectionString"]; 
            MySqlConnection con = new MySqlConnection(str); 
            //MySqlCommand command = con.CreateCommand(); 
            string query = "SELECT * FROM routelog"; 
            //SqlDataAdapter adapter = new SqlDataAdapter(); 
            MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(); 
            myDataAdapter.SelectCommand = new MySqlCommand(query, con); 
            //MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(command); 
            ds= new DataTable(); 
            con.Open(); 
            try 
            { 
                myDataAdapter.Fill(ds); 
            } 
            catch (Exception ex) 
            { 
                WriteLog(DateTime.Now.ToString() + ":" + ex.Message + " " + ex.StackTrace); 
            } 
            finally 
            { 
                con.Close(); 
            } 
            return ds; 
        } 
 
        public static DataSet GetPageInfo()//(int id) 
        { 
            DataSet ds = null; 
            string str = ConfigurationManager.AppSettings["emgConnectionString"]; 
             
            string sequel = "SELECT routelog.starttime, status.details AS STATUS, routelog.sourceaddr, routelog.destaddr, messagebody.data AS 'encrpted message' FROM emg.routelog INNER JOIN emg.status ON (routelog.status = status.statusID)INNER JOIN emg.messagebody ON (routelog.msgid = messagebody.id)WHERE (routelog.msgtype =1)"; 
            //if (id > 0) 
            //    sequel += " WHERE ID = " + id; 
 
            //sequel += " ORDER BY PageName"; 
            try 
            { 
                ds = SqlHelper.ExecuteDataset(str, CommandType.Text, sequel); 
            } 
            catch (Exception ex) 
            { 
                WriteLog(DateTime.Now.ToString()+":"+ ex.Message + " " + ex.StackTrace); 
            } 
            return ds; 
        } 
 
        public static void WriteLog(string msg) 
        { 
            try 
            { 
                //HttpContext context = HttpContext.Current; 
                string path = ConfigurationManager.AppSettings["LogFile"]; 
                //string err = ConfigurationManager.AppSettings["LogFile"]; 
                 
                //Mail.SendMail( 
                //string path = context.Server.MapPath(_path); 
                System.IO.StreamWriter writer = new System.IO.StreamWriter(path, true); 
                writer.WriteLine(msg + " " + DateTime.Now.ToString()); 
                writer.WriteLine(); 
                writer.Close(); 
            } 
            catch { } 
        } 
 
         
    } 
 
     
} 
 

below is also the brief of the grid definition
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"  
            SelectMethod="getDlr" TypeName="com.cellulant.DAL.CommonDataProvider"> 
        </asp:ObjectDataSource> 
<asp:ScriptManager  ID="ScriptManager1" runat="server"></asp:ScriptManager> 
        <!-- content start --> 
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> 
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="RadGrid1"> 
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
            </telerik:RadAjaxManager> 
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True"  
            AllowPaging="True" AllowSorting="True"  
            GridLines="None" ShowGroupPanel="True" Skin="Sunset" PageSize="50" style="margin-bottom: 117px"  
                                    Width="900px" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1"> 
<HeaderContextMenu EnableTheming="True"> 
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
</HeaderContextMenu> 
 
            <ExportSettings FileName="report" IgnorePaging="True" OpenInNewWindow="True"> 
                <Pdf Creator="cellulant Nigreia Limited" PageHeight="8.5in" PageWidth="11in" /> 
            </ExportSettings> 
 
                                    <PagerStyle Mode="NextPrevNumericAndAdvanced" /> 
 
<MasterTableView DataSourceID="ObjectDataSource1"> 
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
</MasterTableView> 
 
            <ClientSettings AllowColumnHide="True" AllowDragToGroup="True"> 
                <Selecting AllowRowSelect="True" /> 
                <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
            </ClientSettings> 
 
<FilterMenu EnableTheming="True"> 
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
</FilterMenu> 
        </telerik:RadGrid> 

when i used the it did not display the returned record from the getDlr funtion. when i ran it in debug mode i found out the about 2500 record was returned but still the grid will not render the data.

i also tried setting the data source of the grid from code behind it still did not render the data. while it renders them with   sqldatasource.

please  i want to know what am doing wrong. and how to get over it.

thanks

Ogunseye E-Larry
Dimo
Telerik team
 answered on 24 May 2010
5 answers
128 views
Hi,
We are using RAD control- Q2 2009 for development.
We have one popup-RadWindow in rtl(right to left) mode. We have configured RadWindow in following manner:

<body style="direction: rtl;">  
    <form id="form1" runat="server">  
    <div> 
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">  
            <Windows> 
                <telerik:RadWindow ID="rw1" Name="rw1" Behaviors="Close" ShowContentDuringLoad="false" 
                    ReloadOnShow="true" VisibleStatusbar="false" BackColor="Gray" Modal="true" runat="server" 
                    Height="650" Width="500">  
                </telerik:RadWindow> 
            </Windows> 
        </telerik:RadWindowManager> 
        <telerik:RadCodeBlock ID="radCodeBlock" runat="server">  
 
            <script language="javascript" type="text/javascript">  
                function OpenRadWindow(url) {  
                    var oWnd = window.radopen(null, 'rw1');  
                    oWnd.setUrl(url);  
                    return false;  
                }          
            </script> 
 
        </telerik:RadCodeBlock> 
        <telerik:RadTextBox ID="txt" runat="server">  
        </telerik:RadTextBox> 
        <asp:Button ID="btnOpen" runat="server" OnClientClick="javascript:return OpenRadWindow('WebForm1.aspx')" 
            Text="pop up 1" /> 
        <asp:Button ID="Button1" runat="server" OnClientClick="javascript:return OpenRadWindow('WebForm2.aspx')" 
            Text="pop up 2 " /> 
    </div> 
    </form> 
</body> 

Even after this I can not see loading image while pop-up load.
If I change direction to ltr then this works successfully.
So, is this any configuration problem or ...?

Please suggest us to resolve this issue.

With Regards,
Naresh Goradara
Rumen
Telerik team
 answered on 24 May 2010
7 answers
164 views
 Hi Team,

I had a RadListbox which connected to sqldatasource.

Afterwhich, when i select the item in the Listbox, it will link me to Radscheduler Advaced Form.

Im able to launch the Advanced form but the ID was not correct.

Please help
Shawn

 protected void RadListBox1_SelectedIndexChanged(object sender, EventArgs e)
     {

         foreach (RadListBoxItem currentItem in RadListBox1.Items)
         {
             String value = currentItem.Value;
             Appointment edittedAppointment = RadScheduler2.Appointments.FindByID(int.Parse(value));
             RadScheduler2.ShowAdvancedEditForm(edittedAppointment);
         }
     }
shawn wong
Top achievements
Rank 1
 answered on 24 May 2010
1 answer
468 views
Hi,

I am attempting to retrieve the value of a cell in a RadGrid during the ItemDataBound event. The catch is that I am using an ItemTemplate, which seems to be the root of the problem.

I found http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html which states (about half-way down) that “This approach of obtaining cell values works for auto-generated columns and built-in column types except for template columns. For template columns you must find the control in the grid cell and extract its value.”

I agree with that statement (based on my testing), but I cannot find anywhere an example of “finding the control in the grid cell and extracting its value.”

Can someone point me to a relevant example?

My goal is to read the URL for a picture (image source), and set an imagecolumn on the same row to use that image source. This approach works perfectly so long as I do not use an <ItemTemplate></ItemTemplate> block.

Thank you in advance for your help.

Brian Meagher

Shinu
Top achievements
Rank 2
 answered on 24 May 2010
2 answers
88 views
I have a master page which has a background in its body.
I have binded my master page with a new Web Page. I added Rad Editor on it.
When I start my web page, the rad editor content itself has the background image which i have set in my master page.

How to solve this issue? I want a white background on Rad Editor instead of the image on my master page.

Below I have posted a screen shot.
Rumen
Telerik team
 answered on 24 May 2010
1 answer
185 views
I understand the whole localization thing that is not my question. Does the radEditor support an end user typing cyrillic characters in the content area? If yes is there any thing special I need to be setting to allow that?

Thanks.
Rumen
Telerik team
 answered on 24 May 2010
1 answer
120 views
Hello, I have a dynamically generated grid in page init.  When the grid has more than 12 editable columns, I set the editform Column Number to 2, so that the edit items are arranged in two columns instead of one.  However, the editform does not resize properly when it is set to two columns as you can see in the attached screenshot.  Is there any solution for this.

Thanks in advance,
Manuel
Dimo
Telerik team
 answered on 24 May 2010
5 answers
564 views
Hello All,

Using RadGrid with 2009.3.1103.35

I have successfully changed the format of displayed column using the format {0:dd/MM/yyyy}  this works well for view mode.  However, when i switch to edit mode, the format reverts to mm/dd/yyyy HH:MM:SS  format.

How can I set the format for both View and edit Mode?  I would prefer not to have to use form templates as this form contains approx 40 columns.

here is the current code for the column I refer to

        <telerik:GridBoundColumn DataField="DateOfBirth" DataType="System.DateTime"  
            Visible = "True" HeaderText="DateOfBirth" SortExpression="DateOfBirth"  
            UniqueName="DateOfBirth" EditFormColumnIndex="1"  
            DataFormatString="{0:dd/MM/yyyy}"> 
        </telerik:GridBoundColumn> 
 


Thanks
Mark
Mark Breen
Top achievements
Rank 1
 answered on 24 May 2010
1 answer
101 views
i just built a style using the stylebuilder for radgrid.. how do i apply the style to my grids? thanks!
Dimo
Telerik team
 answered on 24 May 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?