Highlight Just Edited Row In Cgridview

Dear All,

I am using the similar approach as in this link, yii playground.

When updating row, we need to select the row in CGridView, then the values of the row will be appear in the form below the CGridView. It works great. However, I want to add a feature to highlight, say using yellow color, or to make it simpler, I want the latest updated row in CgridView is being selected. The idea is to give the operator quicker way to make sure the row is being updated.

Any help on this? Thank you in advance.

Kind regards,

Daniel

Ya you can do same like this, just need to add few line of jquery code.

eg. -


$('#main_table table tr').live('click',function(){

   $('#main_table table tr').each(function(){

    	$(this).removeClass('selected'); 

  });

    $(this).addClass('selected');

    return false;

 }); 

this is for you - http://jsfiddle.net/w9brqfmt/

Hi Rohit,

Thank you for the prompt response. However, I am afraid that is not what I need. Probably, my explanation is not clear.

I am actually doing the same thing as in the link. But I want to add one more feature. After save the row, I want to highlight the updated row.




function submitDetail() {

            $.ajax({

                type: 'POST',

                url: "<?php echo Yii::app()->createUrl('/formHeader/addDetail'); ?>",

                data: $('#form-detail-form').serialize(),

                success: formDetailSaved,

                dataType: 'json'

            });

        }


function updateDetail(url) {

        function formDetailSaved(data) {

        if (data.status == "success") {

            $.fn.yiiGridView.update('form-detail-grid');

//            $('#FormDetail_lotName').val("");

//            $('#FormDetail_lotFk').val("");

//            $('#lot-name-saved').val("");

            $('#FormDetail_itemName').val("");

            $('#FormDetail_itemFk').val("");

            $('#item-name-saved').val("");

            $('#FormDetail_quantity').val("");

            $('#FormDetail_unit').val("");

            $('#FormDetail_baseUnit').val("");

            $('#FormDetail_qtyConversion').val("");

            $('#currentUnit').html("");

            $('#altUnit').html("");

            $('#remainingUnit').html("");

            $('#FormDetail_remainingQty').val("");

            $('#stockUnit').html("");

            $('#FormDetail_stockQty').val("");

            $('#FormDetail_locationName').val("");

            $('#location-name-saved').val("");

            $('#FormDetail_newMemo').val("");


            if ($('#FormDetail_id').val() != '') {

                var rowId = "#row-" + $('#FormDetail_id').val();

                $('html,body').animate({scrollTop: ($(rowId).offset().top - 100)}, 500);


                var curRow = $(rowId).get(0);

                $(curRow).trigger('click');

            }


            // delete id to reset update

            $('#FormDetail_id').val("");

            $('#mySubmitButton').html('<i class="icon-plus icon-white"></i>&nbsp');

            toastr.success(data.message, data.title);

        } else {

            toastr.error(data.message, data.title);

        }


        $('input:visible:enabled:first').focus();

    }



Above is my code to save the form and highlight the row. But somehow the trigger click is seemed overwrite by the $fn.yiiGridView.update().

Anyone can help?