1-) C# WebForm DevExpress - Gridview'e Context menü eklemek -> gridview -> designer -> context menu -> enable=true
buna bakmasanda olur -> gridview -> designer ->client-side event->function(s, e){OnContextMenuItemClick(s, e);}
1-) C# WebForm DevExpress - .cs tarafı
protected void grid155_FillContextMenuItems(object sender, DevExpress.Web.ASPxGridViewContextMenuEventArgs e)
{
e.Items.Add("PDF_TEXT", "PDF_NAME", @"images\Add_16x16.png"); // CONTEXTMENU'LERİ BURADA EKLERİZ
e.Items.Add("XLS_TEXT", "XLS_NAME", @"images\Apply_16x16.png");
}
protected void grid155_ContextMenuItemClick(object sender, DevExpress.Web.ASPxGridViewContextMenuItemClickEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.Item.Name + " RowIndex= " + e.ElementIndex); // Output da sonucu görürsün
string id = grid155.GetRowValues(e.ElementIndex, "I_ID").ToString();
switch (e.Item.Name) // NewRow EditRow DeleteRow Refresh
{
case "PDF_NAME":
break;
case "XLS_NAME":
break;
case "NewRow": // Gridview -> Designer -> Contex Menu -> RowMenuItemVisibility den true yapabilirsin
break;
case "EditRow":// Gridview -> Designer -> Contex Menu -> RowMenuItemVisibility den true yapabilirsin
break;
case "DeleteRow":// Gridview -> Designer -> Contex Menu -> RowMenuItemVisibility den true yapabilirsin
break;
case "Refresh":// Gridview -> Designer -> Contex Menu -> RowMenuItemVisibility den true yapabilirsin
break;
}
}
2-) .ASPX tarafında aşıdaki gibi
<dx:ASPxGridView ID="grid155" runat="server" Width="100%" AutoGenerateColumns="False" KeyFieldName="KEYFIELDID" Font-Size="XX-Small" OnFillContextMenuItems="grid155_FillContextMenuItems" OnContextMenuItemClick="grid155_ContextMenuItemClick">
<ClientSideEvents ContextMenuItemClick="function(s, e){OnContextMenuItemClick(s, e);}" />...
...
<script>
function OnContextMenuItemClick(sender, args) {
args.processOnServer = true;
/* JS olarak aşağıyıda kullanabilirsin !!!
var key = sender.GetRowKey(args.elementIndex);
if (isNaN(key)) { // eğer sayı değilse ilk satırdır
key = 0;
}
alert(args.item.name + " RowIndex= " + key);
switch (args.item.name) {
case "ExportToPDF":
alert("ExportToPDF RowIndex= " + key);
break;
case "ExportToXLS":
alert("ExportToXLS RowIndex= " + key);
break;
}
*/
}
</script>