I would like to add one more button next to default button : “CButtonColumn” in the CGridView but dont know how to do it. Also I want to add the id for these buttons to use later in javascript. The id attribute should be :id =“button.$data->id” to easier recognized. Any helps should be great. Thank in advance .
No, that’s not correct. The button identifier is so that the framework knows where to render the button. You can’t really apply a unique HTML id attribute to each button, but you shouldn’t need to. What’s the use case?
List all the items, each item has a button, click on the button run a javacript to display a processed data in this page, not other page. CGridView use for the searching the needed item.
Reason to do this is I dont know how to use ajax in the Yii .
<script type="text/javascript">
$(document).ready(function(){
$('body').on('click', '.my-trigger-button', function(){
// Get the table row that the button is in
var row = $(this).closest('tr');
// Now use jQuery selectors to find and display hidden content in the row
var hiddenContent = row.find('.hidden-content').html();
// Etc
return false;
});
});
</script>
You will need to add the hidden div within one of the existing table cells, it doesn’t really matter which.