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?
jqgrid custom delete dialog message
Asked Answered
Did you use this jgrid : trirand.com/blog ? –
Harebell
What about your previous questions? Do you read the answers? –
Tephra
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:
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.
+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 dot –
Terrazas @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 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();
© 2022 - 2024 — McMap. All rights reserved.