Popup menu in datagrid

Discussion in 'ASP .Net Datagrid Control' started by Grey, Dec 23, 2004.

  1. Grey

    Grey Guest

    is it possible to have popup menu designed within datagrid??
     
    Grey, Dec 23, 2004
    #1
    1. Advertising

  2. Although I have never tried before, I'd definetly like to try to do that..
    You can start off to make a custom datagrid and post questions here to email
    to me if you have some problems..
    will be glad to help :)
    Regards.
    R. Thomas

    "Grey" wrote:

    > is it possible to have popup menu designed within datagrid??
    >
    >
    >
     
    R. Thomas, aka Xtreme.Net, Dec 24, 2004
    #2
    1. Advertising

  3. Is there any reason why that would not work?

    All you need to do is have your datagrid generate custom javascript to
    do transition. I am doing it my application as follows (it is not a
    true popup menu but a pop-up row with a menu):

    Supporting Javascript:
    <script language="javascript">
    var shownid;
    function showobj(obj) {
    if(obj==null)return;
    if(obj!=null){
    if(shownid==obj) return;
    document.getElementById(obj).style.display =
    'block';
    }
    if (shownid!=null)
    document.getElementById(shownid).style.display
    = 'none';
    shownid=obj;
    }

    </script>


    Last columns of the datagrid - CheckOutTS is the actual last field
    displayed in the row:
    <asp:TemplateColumn HeaderText="Check Out Date"
    SortExpression="CheckOutTS">
    <ItemStyle Wrap="False"></ItemStyle>
    <ItemTemplate>
    <%#Databinder.eval(Container.DataItem,"CheckOutTS")%>
    <asp:placeHolder Runat="server"
    OnDataBinding="PutActions"
    ID="Placeholder1"></asp:placeHolder>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    <PagerStyle Position="Bottom"
    Mode="NumericPages"></PagerStyle>
    </asp:datagrid>

    Now the PutActions excerpts:
    Protected Sub PutActions(ByVal sender As Object,
    ByVal e As EventArgs)
    'Container cell for popup row actions
    Dim td As New HtmlTableCell

    td.ColSpan = 6 'this number depends on how many columns you
    have in your grid
    Dim dti As DataGridItem = _
    CType(sender.bindingcontainer, DataGridItem)
    Dim plc As PlaceHolder = CType(sender, PlaceHolder)
    td.VAlign = "Top"
    'add actions to pop-up row:
    dim lb as LinkButton

    LinkButton lb = New LinkButton
    lb.Text = "Action 1"
    lb.CommandArgument = dbRecord("ID")
    AddHandler lb.Command, AddressOf Action1Handler
    td.Controls.Add(lb)

    LinkButton lb = New LinkButton
    lb.Text = "Action 2"
    lb.CommandArgument = dbRecord("ID")
    AddHandler lb.Command, AddressOf Action2Handler
    td.Controls.Add(lb)
    '... etc..

    'add on mouseover event to row using ID column as unique key
    dti.Attributes.Add("onmouseover",
    "JavaScript:showobj('actions" & dbRecord("ID") & "');")
    'INSERT constructed hidden ROW into DataGrid using ID column
    as unique key
    plc.Controls.Add(New LiteralControl("</TR><TR id='actions" &
    dbRecord("ID") & "' style='Display:none'>"))
    plc.Controls.Add(td)
    end sub

    Now if you are good with JS Menues you can do something much more
    sophisticated. With this code I was able to build a cool looking
    roll-over effect. I also build my action list dynamically so it is
    context sensetive (depending on a row)
    It would be interesting to see more posts on this topic!
    On Thu, 23 Dec 2004 23:19:10 -0800, "R. Thomas, aka Xtreme.Net"
    <NoSpam(> wrote:

    >Although I have never tried before, I'd definetly like to try to do that..
    >You can start off to make a custom datagrid and post questions here to email
    >to me if you have some problems..
    >will be glad to help :)
    >Regards.
    >R. Thomas
    >
    >"Grey" wrote:
    >
    >> is it possible to have popup menu designed within datagrid??
    >>
    >>
    >>
     
    Igor Stavnitser, Dec 31, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grey

    Popup menu in datagrid

    Grey, Dec 23, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    639
    Saravana
    Dec 24, 2004
  2. =?Utf-8?B?Sm9obiBXYWxrZXI=?=

    Popup Window Popup Timing

    =?Utf-8?B?Sm9obiBXYWxrZXI=?=, Nov 4, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    847
    =?Utf-8?B?Sm9obiBXYWxrZXI=?=
    Nov 4, 2005
  3. dapkniht
    Replies:
    1
    Views:
    1,338
    Eliyahu Goldin
    Mar 8, 2006
  4. Perry Loh
    Replies:
    0
    Views:
    302
    Perry Loh
    Mar 24, 2006
  5. Jens Peter Hansen
    Replies:
    7
    Views:
    544
    Randy Webb
    Jun 19, 2004
Loading...

Share This Page