This is a migrated thread and some comments may be shown as answers.

[Solved] RadGridEmpty

4 Answers 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DK
Top achievements
Rank 2
DK asked on 01 Jul 2009, 12:03 PM
hello.
i have a grid and on page load i want to show only the column names of the grid and there is a link button inside the commanditem.
when i click on  the link button a popup opens and i chose a column data from that popup and press submit .that popup closes and on the close of that pop up i want  a new row should be added to the grid which contains the chosen item and other 5 columns with textbox,datepicker and checkbox with no data.

and also there should be hierarchy in the grid.
  please help me in this problem.
i will be highly obliged to you people.
thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Jul 2009, 04:48 AM
Hello,

Try out the following steps and let me know if it helps meet your requirement:
1) You need to add the required number of BoundColumns and the Template Columns(having textboxes,checkbox etc)
aspx:
 <telerik:RadGrid ID="RadGrid1" runat="server"  GridLines="None" AutoGenerateColumns="False" OnNeedDataSource="RadGrid1_NeedDataSource"
       <MasterTableView CellSpacing="-1"
             <Columns> 
                    <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Click"
                        <ItemTemplate> 
                            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridBoundColumn DataField="CustomeriD" HeaderText="Customer" UniqueName="column"
                    </telerik:GridBoundColumn> 
              </Columns> 
        </MasterTableView> 
 </telerik:RadGrid> 

2) To initially display only headers set the datasource of the grid to an empty object collection
c#:
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
    { 
      if(!IsPostBack) 
         RadGrid1.DataSource = new object[] { }; 
      else 
        { 
             //select query based on selection from the pop up window i.e., Session["CustomerID"] 
 
        } 
    } 

3) On selecting an item from the pop up window, you can store the selected value in a session variable and register a client script as shown below:
c#
 
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
            DropDownList ddlList = (DropDownList)sender;        
            Session["CustomerID"] = ddlList.SelectedValue; 
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey""CloseAndRebind();"true); 
             
    }  

4) You can then call a refreshGrid function defined in the Browser window  so as to pass window parameters , as shown below:
js:
function CloseAndRebind(args)   
        {   
            GetRadWindow().Close();   
            GetRadWindow().BrowserWindow.refreshGrid(args);   
        }   

5) In the refreshGrid function defined in the main page, you should, in turn, fire an ajax request:
js:
function refreshGrid(arg) 
           { 
             if(!arg) 
             { 
             $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");              
             } 
           } 

6) Finally, rebind the grid in the AjaxRequest server side event:
c#:
 
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
        { 
            if (e.Argument == "Rebind"
            { 
                      RadGrid1.Rebind(); 
            }             
        }  

Princy.
0
DK
Top achievements
Rank 2
answered on 02 Jul 2009, 05:04 AM
thnaks for your valuable answer.
my problem get solved.
thanks a lot
0
DK
Top achievements
Rank 2
answered on 02 Jul 2009, 05:51 AM
i have a little problem more.
i have a hierarichal grid.
on addition of the first row in the grid i want t oexpand the hierarichal row of that row.
and on that row i want to add new records.

first row contains something like employyeID,Employee adress,employee email
the corresponding hierarichal row contains employee depatrments,employeeBU etc.
how coude i do it.

i want to add screenshot here for my project but from where i can add attachments?

0
DK
Top achievements
Rank 2
answered on 02 Jul 2009, 06:34 AM
i am not using radwindow.
instead of radwindow i m using panle and modelpopup extender.
please clear the function
function CloseAndRebind(args)   
        {   
            GetRadWindow().Close();   
            GetRadWindow().BrowserWindow.refreshGrid(args);   
        }

Tags
Grid
Asked by
DK
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
DK
Top achievements
Rank 2
Share this question
or