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

Trying to Emulate Cardview

2 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lynn
Top achievements
Rank 2
Lynn asked on 30 Aug 2010, 05:27 AM
I am attempting to emulate (to some extent) the Cardview sample for the grid.  However, there are two differences that I need in my grid compared to the Cardview sample.

First, the grid as I now have displays per the screen capture below named TelerikCardviewQuestion1.gif.  As you can see, I have a wide display of an asp:label control that contains long text.  Below that I have two lines that contain a user id and a date posted.

The code in the .aspx file that displays this grid is: 
<h5><asp:Label ID="ViewCommentsHdg" runat="server" Text="Comments" Visible="false" ></asp:Label></h5>
<telerik:RadGrid ID="RadGrid2" runat="server" AutoGenerateColumns="False" AllowPaging="True" Enabled="false" Visible="false"
     GridLines="None" 
    Width="450px" EnableEmbeddedSkins="true" BackColor="#11161D" Skin="Black" OnItemCreated="RadGrid2_ItemCreated" >
<PagerStyle Mode="NumericPages" PageButtonCount="5" />
<PagerStyle Mode="NumericPages" AlwaysVisible="true"></PagerStyle>
    <MasterTableView TableLayout="Fixed">
        <ItemTemplate>
            <asp:Label ID="Image1" Text='<%# Eval("TextLangLongBody1") %>' runat="server"  />
            <div>
                <span style="font-weight: bold;"></span>
                <%# Eval("UserUName")%>
                <br />
                <span style="font-weight: bold;"></span>
                <%# Format(Eval("TextRunFromDate"), "General Date")%>
                <br />
            </div>
            <br />
        </ItemTemplate>
    </MasterTableView>
    <ClientSettings AllowDragToGroup="false">
        <Scrolling AllowScroll="true" UseStaticHeaders="true" />
    </ClientSettings>
</telerik:RadGrid>
There is also one column defined in the code behind file in the Page_Init event is:
Dim boundcolumn As GridBoundColumn
boundcolumn = New GridBoundColumn
Me.RadGrid2.Columns.Add(boundcolumn)
boundcolumn.UniqueName = "TextLangLongBody1"
boundcolumn.DataField = "TextLangLongBody1"
boundcolumn.Visible = True
boundcolumn = Nothing
RadGrid2.Enabled = True
RadGrid2.Visible = True
It seems redundant to need this code in the code behind.  Your Cardview sample does not contain it.  But If I comment out just the "column add" statements above (so that the .Enabled = True and .Visible = True are still active) then the grid displays no records what soever.  This is causing me some concern because the .aspx file contains a definition for adding TextLangLongBody1 to the grid.  I don't understand why both are needed.

Additonal issues:
(1) I would like the display of the user id and the date posted to be in a separate column from the TextLangLongBody1.  I would like these two rows to be displayed as the first column in the grid.
(2) I would like the display of the TextLangLongBody1 to be the second column in the grid.
(3) I have tried moving the asp:Label control down below the <div> containing the user id and date, but all that accomplishes is moving the text below those two fields.  It does not create a second column.

Here are my specific questions:
(1) Why does my grid require the Page_Init column definition code to work?  This is not required in your Cardview example.
(2) I think I have emulated the Cardview code exactly and yet I only get one column in the grid and not two.  Why?  Later, in another version of this same grid, I want to add an additional column containing a small display of the user's selected avatar graphic.  So I need to resolve this version now so I can build on it later.

I must be missing something really basic, but....?

Thanks in advance for any assistance!

Lynn



2 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 02 Sep 2010, 09:28 AM
Hi Lynn,

Please try setting AutoGenerateColumns property to true and let me know if the issue still persist.

All the best,
Pavlina
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Lynn
Top achievements
Rank 2
answered on 02 Sep 2010, 06:47 PM
Pavlina,

Thank you for your assistance.  Your recommendation did resolve the requirement for the column defined in the code-behind file.

I found an example at http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html#Creating_template_columns_programmatically that told me how to programmatically create the template column.  It's working great!

Between your assistance and help text I found, my problems are resolved!

Thanks again!

Lynn
Tags
Grid
Asked by
Lynn
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Lynn
Top achievements
Rank 2
Share this question
or