RadGrid AutoGenerateColumns false

4 posts, 1 answers
  1. Saul
    Saul avatar
    3 posts
    Member since:
    Jul 2015

    Posted 06 Jul 2015 Link to this post

    Hi! I'm trying to make a radgrid with explicit defined columns. I've tried setting the AutoGenerateColumns property of the radgrid to false, but it won't show anything. This is my code

    <telerik:RadGrid ID="rdContainers"  runat="server" AutoGenerateColumns="false" OnNeedDataSource="fnGetScanContainers" AllowFilteringByColumn="True" Width="91%">
                        <telerik:MasterTableView  TableLayout="Fixed">
                            <HeaderStyle Width="102px" />
                            <Columns>
                                <telerik:GridBoundColumn DataField="ContainerID" HeaderText="Container ID" SortExpression="ContainerID" UniqueName="gcContainerID" FilterControlWidth="60px">
                                    <HeaderStyle Width="170px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Location" HeaderText="Location" UniqueName="gcLocation" FilterControlWidth="60px">
                                     <HeaderStyle Width="115px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="PartNumber" HeaderText="Part Number" UniqueName="gcPartNumber" FilterControlWidth="60px">
                                     <HeaderStyle Width="115px" />
                                </telerik:GridBoundColumn>
                        </telerik:MasterTableView>
                        <ClientSettings EnableRowHoverStyle="true">
                                    <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" />
                                    <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="" />
                        </ClientSettings>
    </telerik:RadGrid>

     

  2. Saul
    Saul avatar
    3 posts
    Member since:
    Jul 2015

    Posted 06 Jul 2015 in reply to Saul Link to this post

    If I remove the AutoGenerateColumns="false" the RadGrid shows all the columns from my DataTable source. However, I'd like to define the columns by myself. This is how I set the DataSource

    protected void fnGetScanContainers(object sender, EventArgs e) {
                objScanContainer = new ScanContainer();
                rdContainers.DataSource = objScanContainer.GetHDDReceivedDescription();  //This function retrieves the DataTable
    }

  3. Saul
    Saul avatar
    3 posts
    Member since:
    Jul 2015

    Posted 07 Jul 2015 Link to this post

    Nevermind, the problem was in my MasterTableView tag

  4. Answer
    Viktor Tachev
    Admin
    Viktor Tachev avatar
    2342 posts

    Posted 08 Jul 2015 Link to this post

    Hello Saul,

    I have examined the provided code and the closing Columns tag seems to be missing. Try to add it and see how the behavior changes.


    <telerik:RadGrid ID="rdContainers" runat="server" AutoGenerateColumns="false" OnNeedDataSource="fnGetScanContainers" AllowFilteringByColumn="True" Width="91%">
        <telerik:MasterTableView TableLayout="Fixed">
            <HeaderStyle Width="102px" />
            <Columns>
                <telerik:GridBoundColumn DataField="ContainerID" HeaderText="Container ID" SortExpression="ContainerID" UniqueName="gcContainerID" FilterControlWidth="60px">
                    <HeaderStyle Width="170px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Location" HeaderText="Location" UniqueName="gcLocation" FilterControlWidth="60px">
                    <HeaderStyle Width="115px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PartNumber" HeaderText="Part Number" UniqueName="gcPartNumber" FilterControlWidth="60px">
                    <HeaderStyle Width="115px" />
                </telerik:GridBoundColumn>
            </Columns>
        </telerik:MasterTableView>
        <ClientSettings EnableRowHoverStyle="true">
            <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" />
            <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="" />
        </ClientSettings>
    </telerik:RadGrid>



    Regards,
    Viktor Tachev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top