0

I'm trying to refresh the grid, but i get this error:

TypeError: $.fn.GridView is undefined

This is my js code:

$( document ).ready(function() {
        $("#username_filter").keyup(function( event ) {
            if ($(this).val().length >3){
                $.ajax({
                    url: "/common/main/filterData/",
                    type: "POST",
                    data: { username : $(this).val() },
                }).done(function() {
                    $.fn.GridView.update("#yw0");
                });
            }
        });
    });

and this is the view:

.....
$this->widget('GridView', array(
        'dataProvider' => $data,
        //'filter' => '',
        'itemsCssClass'=>'table',
        'pager' => array(
                'class'                 => 'CLinkPager',
                'prevPageLabel'         => 'Previous',
                'nextPageLabel'         => 'Next',
                'header'                => '',
                'previousPageCssClass'  => 'btn btn-info btn-sm',
                'selectedPageCssClass'  => 'btn btn-warning btn-sm',
                'internalPageCssClass'  => 'btn btn-info btn-sm',
                'firstPageCssClass'     => 'btn btn-info btn-sm',
                'nextPageCssClass'      => 'btn btn-info btn-sm',
        ),
....

Maybe it is a noob question, but where is generated the id of the grid ?

2 Answers 2

2

you can specify custom id for GridView just specify id attribute for grid view options

$this->widget('GridView', array(
    'id' => 'my_grid_id',
    'dataProvider' => $data,
    // ...
);

for manual update try this

$('#' + id).yiiGridView('update');
Sign up to request clarification or add additional context in comments.

Comments

0

it should be

$.fn.yiiGridView.update("yw0");

not $.fn.GridView

to set the id of gridview, just specify id attribute for grid view. example:

$this->widget('GridView', array(
    'id' => 'custom_id',
    .....
));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.