We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Context Menu in child grids

Hello,

I have this code to generate child grids, but the context menu only works with the first child grid that is expanded:

function detailGridDataDimensionesCOFs(e)
{
var data = e.data.CuentasDimensionesCOFRows;

var idControl = e.model.clientId.replace("_ctl01_GdcCOFsDimensiones", "");

idControl = idControl + "_ctl00_HFColumnasAsignaciones";
var result = document.getElementById(idControl).value;
var Columnas = JSON.parse(result);

var CM = [];
if (COSoloLectura())
{
CM = [TextoEDITARFORMULAS, TextoVERASIGNACION] ;
} else {
CM = [TextoEDITARFORMULAS, TextoVERASIGNACION, TextoELIMINARESTEIMPACTO, TextoELIMINARTODASLASFORMULASDELIMPACTO, TextoRECUPERARFORMULASORIGINALES];
}

var g = e.detailsElement.find("#detailDimensionesCOFs").ejGrid({
dataSource: data,
locale: GetLocale(),
allowSelection: true,
columns: Columnas,
editSettings: { allowAdding: false, allowEditing: false },
contextMenuSettings: { enableContextMenu: true, contextMenuItems: [], customContextMenuItems: CM },
contextClick: 'contextClick_detailDimensionesCOFs',
queryCellInfo: function (args) { GdcCOFsDimensionesAsignaciones_QueryCellInfo(args); },
toolbarSettings: { showToolbar: false },
allowResizeToFit: true,
idPadre:e.model.clientId
});
}

Thanks!

1 Reply

RU Ragavee U S Syncfusion Team February 12, 2016 12:03 PM UTC

Hi Jorge,

Thanks for contacting Syncfusion Support.

Since all expanded detail Grid have same id, the reported issue has occurred. So we suggest you to define the detail Grid with unique id to resolve the issue. Please refer to the below code example.

<script id="GridContents" type="text/x-jsrender">       

            <div id="detailGrid{{:EmployeeID}}"></div><%--defining the element id with unique EmployeeID value.--%>       
    </script>

<script type="text/javascript">

       function detailGridData(e) {

            var filteredData = e.data["EmployeeID"];

           . . . .

//rendering the Grid control by finding the unique ID

            e.detailsElement.find("#detailGrid"+filteredData).ejGrid({

                . . . .

           });           

        }
    </script>


Also, from your code snippets, we found that you have explicitly modified the clientid and passed it to the detail grid model using “idPadre”. Since we don’t have any such property in grid, this wont affect the element id of the Grid.

For your convenience, we have created a sample which can be downloaded from the below location.

Sample Link: http://www.syncfusion.com/downloads/support/forum/122050/ze/Sample80693589

Regards,
Ragavee U S.

Loader.
Live Chat Icon For mobile
Up arrow icon