jqgrid custom delete dialog message
Asked Answered
S

2

9

I want to customize the delete dialog message. Based on a selected row? I want to display a message something like "Delete selected row: $selectedRow.columnValue? " How can i do that?

Slosberg answered 2/8, 2011 at 14:22 Comment(2)
Did you use this jgrid : trirand.com/blog ?Harebell
What about your previous questions? Do you read the answers?Tephra
T
16

You can use beforeShowForm or afterShowForm of the delGridRow to overwrite the text of the conformation dialog.

For example

beforeShowForm: function ($form) {
    $("td.delmsg", $form[0]).html("Do you really want delete the row with <b>id=" +
         $("#list").jqGrid('getGridParam','selrow') + "</b>?");
}

(see the old demo) will display the confirmation dialog like the following:

enter image description here

You can easy modify the example to display any other information about the deleting row. You can use getRowData or getCell to get some information from the deleting row.

UPDATED: See the answer for additional information.

Tephra answered 2/8, 2011 at 15:29 Comment(8)
+1 - yeah, I didn't think when I wrote my answer earlier. Thanks. You're definitely the jqgrid guru!Viceregent
@Oleg: Hei, nice solution. But what if I want to get the message from server side? How do I specify the Url from which the message should be loaded? I am using .Net MVC 3.Tropaeolin
@Mohaimin: It's full depend on how you use jqGrid in ASP.NET MVC 3. If you has $("td.delmsg", $form[0]).html(...) inside of aspx page for example the text "Do you really want delete the row with <b>id=" can be generated by server code and be not a constant.Tephra
If id contains dot . or other special characters, hex code appears instead. How to show real id in delete prompt ?Terrazas
@Tephra If there are multiple selected rows, how to select all row ids in prompt ? How to show id if it contains . or other special characters ? Currently hex code appears instead of dotTerrazas
@Andrus: The current question has no relation to keyboard navigation. I posted you already the demo which shows that if one set attributes href: "#", role: "button" and tabindex on the buttons of Delete dialog then one can set focus by usage $("#dData").focus().Tephra
@Tephra I modified comments and removed keyboard navigation parts. Questions about multiple ids print and id decoding are kept since those are related to this question.Terrazas
@Andrus: I tried, but I could not reproduce any problem with ids having .. See the demo.Tephra
F
2

if you start dialog with $('#dialog_id') then before you open your dialog change his html

$('#dialog_id').html('Delete selected row:' + $selectedRow.columnValue?);
$('#dialog_id').dialog();
Foppish answered 2/8, 2011 at 14:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.