asp.net - RadContextMenu inside RadGrid does not show up when placing RadGrid inside Panel/div with visible false -


below code using show radcontextmenu when right click on radgrid rows:

html:

    <telerik:radcodeblock runat="server" id="radcodeblock3">             <script type="text/javascript" src="~/javascript/clienteventscript.js"></script>             <script type="text/javascript">                 ; (function ($, undefined) {                     var menu;                     var grid;                     var demo = window.demo = {};                      window.onload = function () {                         grid = $telerik.findcontrol(document, "rginvoice");                         menu = $telerik.findcontrol(document, "radmenu1");                     }                      demo.showcolumnheadermenu = function (event, columnname) {                          var columns = grid.get_mastertableview().get_columns();                         (var = 0; < columns.length; i++) {                             if (columns[i].get_uniquename() == columnname) {                                 columns[i].showheadermenu(event, 75, 20);                             }                         }                     };                      demo.rowcontextmenu = function (sender, eventargs) {                         var evt = eventargs.get_domevent();                         if (evt.target.tagname == "input" || evt.target.tagname == "a") {                             return;                         }                          var index = eventargs.get_itemindexhierarchical();                         document.getelementbyid("radgridclickedrowindex").value = index;                          sender.get_mastertableview().selectitem(sender.get_mastertableview().get_dataitems()[index].get_element(), true);                          menu.show(evt);                         evt.cancelbubble = true;                         evt.returnvalue = false;                          if (evt.stoppropagation) {                             evt.stoppropagation();                             evt.preventdefault();                         }                     };                 })($telerik.$);             </script>         </telerik:radcodeblock>  <div id="divgrid" runat="server" visible="false">     <%--<asp:panel id="panel1" runat="server" visible="false">--%>      <telerik:radgrid id="rginvoice" runat="server" allowsorting="true" autogeneratecolumns="false"                             emptydatatext="no record available." onneeddatasource="rginvoice_needdatasource" visible="true"                             allowautomaticinserts="false" allowautomaticupdates="false" allowautomaticdeletes="true"                              enableembeddedskins="false" imagespath="~/app_themes/metrored/grid" skin="metrored" gridlines="both"             enableheadercontextmenu="true" enableheadercontextfiltermenu="true">                              <mastertableview showheaderswhennorecords="true" autogeneratecolumns="false" insertitemdisplay="top"                             insertitempageindexaction="showitemoncurrentpage" showfooter="true" commanditemdisplay="top" enablecolumnsviewstate="false">                                  <commanditemsettings showaddnewrecordbutton="false" />                                 <columns>                                                       <telerik:gridboundcolumn headertext="sp id" datafield="spfoid" sortexpression="spfoid">                                    </telerik:gridboundcolumn>                                     <telerik:gridboundcolumn headertext="direct cost" datafield="dcidescription" sortexpression="dcidescription">                                    </telerik:gridboundcolumn>                                    <telerik:gridboundcolumn headertext="business unit" datafield="buname" sortexpression="buname">                                    </telerik:gridboundcolumn>                                    <telerik:gridboundcolumn headertext="status" datafield="status" sortexpression="status">                                    </telerik:gridboundcolumn>                                  </columns>                                            <groupbyexpressions>                                                 <telerik:gridgroupbyexpression>                                                     <groupbyfields>                                                         <telerik:gridgroupbyfield fieldname="businessunit" sortorder="ascending" />                                                     </groupbyfields>                                                     <selectfields>                                                         <telerik:gridgroupbyfield fieldname="businessunit" headertext="business unit" />                                                     </selectfields>                                                 </telerik:gridgroupbyexpression>                                             </groupbyexpressions>                             </mastertableview>              <clientsettings>                <clientevents onrowcontextmenu="demo.rowcontextmenu" />                <selecting allowrowselect="true" />                <scrolling allowscroll="false"></scrolling>             </clientsettings>         </telerik:radgrid>      <input type="hidden" id="hidden1" name="radgridclickedrowindex" />      <telerik:radcontextmenu id="radcontextmenu1" runat="server" onitemclick="radmenu1_itemclick"         enableroundedcorners="true" enableshadows="true">         <items>             <telerik:radmenuitem text="add">             </telerik:radmenuitem>             <telerik:radmenuitem text="edit">             </telerik:radmenuitem>             <telerik:radmenuitem text="delete">             </telerik:radmenuitem>         </items>     </telerik:radcontextmenu>   <%--</asp:panel>--%>     </div> 

c#:

protected void btninvoice_click(object sender, eventargs e)     {         divgrid.visible = true;         //panel1.visible = true;         btninvoice.enabled = false;     }      #region invoice     protected void rginvoice_needdatasource(object sender, gridneeddatasourceeventargs e)     {         try         {             _dtinvoice = sdm.invoice.getinvoice(_spid);             rginvoice.datasource = _dtinvoice;         }         catch (exception ex)         {         }     }     #endregion      #region radmenu     protected void radmenu1_itemclick(object sender, radmenueventargs e)     {         int radgridclickedrowindex;          radgridclickedrowindex = convert.toint32(request.form["radgridclickedrowindex"]);          switch (e.item.text)         {             case "edit":                 rginvoice.items[radgridclickedrowindex].edit = true;                 rginvoice.rebind();                 break;             case "add":                 rginvoice.mastertableview.isiteminserted = true;                 rginvoice.rebind();                 break;             case "delete":                 rginvoice.mastertableview.performdelete(rginvoice.items[radgridclickedrowindex]);                 break;         }     }     #endregion 

i followed below link above implementation: http://demos.telerik.com/aspnet-ajax/grid/examples/columns-rows/columns/context-menu/defaultcs.aspx

everything working fine except when put radgrid inside panel/div , make visible=false in html code , try make visible=true on button click event, radcontextmenu not show up.

radcontextmenu shows when panel/div visible.

but requirement have show radgrid on button click along radcontextmenu.

please let me know how hide , show radgrid on button click without issue in data binding in showing radcontextmenu.

please reply.

thanks in advance

function rowcontextmenu(sender, args) {     var menu = $find("<%=radmenu1.clientid %>");     var evt = args.get_domevent();      if (evt.target.tagname == "input" || evt.target.tagname == "a") {         return;     }      var index = args.get_itemindexhierarchical();     document.getelementbyid("radgridclickedrowindex").value = index;      sender.get_mastertableview().selectitem(sender.get_mastertableview().     get_dataitems()[index].get_element(), true);     menu.show(evt);     evt.cancelbubble = true;     evt.returnvalue = false;     if (evt.stoppropagation) {         evt.stoppropagation();         evt.preventdefault();     } } 

id name wrong

<input type="hidden" id="hidden1" name="radgridclickedrowindex" /> 

id "radgridclickedrowindex"

copy paste code never work. in telerik.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -