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

Filtering on Detail table always returning blank screen for me

2 Answers 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JeremyP
Top achievements
Rank 1
JeremyP asked on 24 Sep 2008, 04:25 PM

I can't figure it out.  I have AllowFilteringByColumn set to true on the main grid, so I thought it was supposed to allow it for all underlying tables, but everytime I attempt filtering a details table, I get a blank screen.

Here's the code:
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True"
        AllowPaging="True" AllowSorting="True" GridLines="None"
        ondetailtabledatabind="RadGrid1_DetailTableDataBind"
        onneeddatasource="RadGrid1_NeedDataSource" Skin="WebBlue">
       
        <MasterTableView AutoGenerateColumns="false" DataKeyNames="ProjNo">
            <DetailTables>
                <telerik:GridTableView runat="server" ShowFooter="True">
                    <RowIndicatorColumn>
                        <HeaderStyle Width="20px" />
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn>
                        <HeaderStyle Width="20px" />
                    </ExpandCollapseColumn>
                </telerik:GridTableView>
            </DetailTables>
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn Visible="True">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
            <telerik:GridBoundColumn DataField="ProjNo" DataType="System.Int32"
            HeaderText="Project Number" ReadOnly="True" SortExpression="ProjNo"
            UniqueName="ProjNo">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="ProjectName" HeaderText="Project Name"
            SortExpression="ProjectName" UniqueName="ProjectName">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DateCreated" DataType="System.DateTime"
            HeaderText="Date Created" SortExpression="DateCreated"
            UniqueName="DateCreated">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="ProjectStatus" HeaderText="Project Status"
            SortExpression="ProjectStatus" UniqueName="ProjectStatus">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="POCName" HeaderText="Point Of Contact"
            ReadOnly="True" SortExpression="POCName" UniqueName="POCName">
        </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings>
            <Scrolling AllowScroll="True" UseStaticHeaders="True" />
        </ClientSettings>
        <FilterMenu EnableTheming="True" Skin="Vista">
            <CollapseAnimation Type="OutQuint" Duration="200">
            </CollapseAnimation>
        </FilterMenu>
       
    </telerik:RadGrid>

 

CODE BEHIND:

private string user = "jrpuser";
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        GridData gd = new GridData();
        RadGrid1.DataSource = gd.GetProjects(user);
    }
    protected void RadGrid1_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
    {
        GridData gd = new GridData();
        GridDataItem masterItem = (GridDataItem)e.DetailTableView.ParentItem;
        e.DetailTableView.DataSource = gd.GetProjectDetails(user, Convert.ToInt16(masterItem.GetDataKeyValue("ProjNo")));
    }

BUSINESS OBJECTS:

public DataTable GetProjects(string user)
        {
            SqlDataAdapter da = null;
            DataTable table = new DataTable();
            SqlConnection conn = null;
            SqlCommand cmd = null;
            string connection;
            piiConnection strcon = new piiConnection();
            try
            {
                connection = strcon.getConnection();
                conn = new SqlConnection(connection);
                cmd = new SqlCommand("spGetProjects", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@User", user));
                da = new SqlDataAdapter(cmd);
                conn.Open();
                da.Fill(table);
            }
            finally
            {
                conn.Close();
            }
            return table;
        }
        public DataTable GetProjectDetails(string user, int id)
        {
            SqlDataAdapter da = null;
            DataTable table = new DataTable();
            SqlConnection conn = null;
            SqlCommand cmd = null;
            string connection;
            piiConnection strcon = new piiConnection();

            try
            {
                connection = strcon.getConnection();
                conn = new SqlConnection(connection);
                cmd = new SqlCommand("spGetProjectDetails", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@User", user));
                cmd.Parameters.Add(new SqlParameter("@ProjNo", id));
                da = new SqlDataAdapter(cmd);
                conn.Open();
                da.Fill(table);
            }
            finally
            {
                conn.Close();
            }
            return table;
        } 

2 Answers, 1 is accepted

Sort by
0
JeremyP
Top achievements
Rank 1
answered on 24 Sep 2008, 06:18 PM
IOW, there is an error somewhere because nothing is beting returned other than a blank html page.

Any clue as to why filtering works on the main table but not on the details table?
0
Yavor
Telerik team
answered on 29 Sep 2008, 07:40 AM
Hi Jeremy,

I tested the setup which you mentioned, and the control behaved consistently.
Attached to this message, you will find the code, which I used for testing.
Take a look at it and let me know if I am leaving something out.

Regards,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
JeremyP
Top achievements
Rank 1
Answers by
JeremyP
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or