You can use jQuery to get the value of the first column to be displayed in the confirmation text…
this jQuery code will get the value of the first column: $(this).parent().parent().children(’:first-child’).text()
and you can use it like:
...
'deleteConfirmation'=>"js:'Attenzione: L\'eliminazione di anno '+$(this).parent().parent().children(':first-child').text()+' porterà i file abbinati a quellanno nella categoria generica \"Archivio bilanci\". L\'operazione non è reversibile. Desideri continuare?'",
...
NOTE: the "js:" at the beginning… and the proper use of double and single quotes…
I will only add that in this post you will find example, how to read contents of other column than first and use in in delete confirmation message box.
For the explanation of the “complex” jQuery read the comment #6 on this thread… you will see that this line works only for a click on a button in the CButtonColumn… as you are using selectionChanged… you don’t know where the user has clicked as he can click anywhere on the row…
I’m so perplexed that I forgot to explain about that .
Basically, I want to pass the content of the second column (in the selected row) to textfield in another window.
So, when user checks the checkbox, the ‘distributor id’ column content (of the selected row) will be passed to distributor id textfield in another window.
Wow! Looks very cool. Thanks a million for giving a detailed example, mdomba.
Edit: It works when page loads for the first time. Anyway, I notice that this event is not triggered after I do some filtering (search function) in CGridView. Any idea?
Instead of multiple calls to parent(), you can also make a single call to parents(), passing ‘tr’ as the selector, so instead of this, which would take the text from the 4th column of the table (the :eq selector uses 0-based numbering):
'deleteConfirmation'=>"js:'Are you sure you want to delete the user ' +
$(this).parent().parent().children(':eq(3)').text() +
'? This operation cannot be undone.\\n\\nPress \"OK\" to delete, or \"Cancel\" to abort without deleting.\\n\\n'",
You could use this:
'deleteConfirmation'=>"js:'Are you sure you want to delete the user ' +
$(this).parents('tr').children(':eq(3)').text() +
'? This operation cannot be undone.\\n\\nPress \"OK\" to delete, or \"Cancel\" to abort without deleting.\\n\\n'",
Will it also be problem, if all AJAX calls of CGridView (sorting, pagination) will be changed to normal POST calls?
I mean - is it truly only a problem of reloading CGridView after AJAX call or maybe this little trick interference somehow, how CGridView works at all?