0

I have a view with a parent-child subview layout. In the parent view, I have a GridView from the YiiBooster extension that lists all the people in the db:

$this->widget('bootstrap.widgets.TbGridView', array(
        'dataProvider' => $model->search(),
        'filter' => $model,
        'ajaxUpdate' => true,
        'selectionChanged' => "updateChild", // new code
        'columns' => array(
            'firstName', 'lastName'
        )
    ));

It doesn't have an id, and is assigned one by default, which is yw0.

The updateChild js method called on selectionChanged gets all the information of a person and updates the child view with the information using $('#childView').html(data). If the parent GridView is given an explicit ID, like so:

$this->widget('bootstrap.widgets.TbGridView', array(
        'id' => 'parentGrid' // explicit id
        'dataProvider' => $model->search(),
        'filter' => $model,
        'ajaxUpdate' => true,
        'selectionChanged' => "updateChild", // new code
        'columns' => array(
            'firstName', 'lastName'
        )
    ));

The child view does not update with relevant data. I took a look at the source, and the function in the controller worked fine, and passed all relevant data back, it's a rendering issue, they were refusing to display.

Also, if I have another GridView in my child view somewhere (such as listing the various different categories a person belongs to), then I get the following error when trying to click on a person: "cannot read property tableClass of undefined".

My child view is a partial view, and thus renderPartial() is used. I allow it to load in more scripts, since my child view has js listeners for click events on various elements in the child view.

Does anyone have any ideas as to what's going on? Thanks.

EDIT: I have gotten things working with explicit ID's now, I got the answer from another question. However the "cannot read property tableClass of undefined" problem still exists. It seems that when I want to put a GridView into my child view through renderPartial(), it messes up the GridView in the parent view.

Andy Hall
  • 454
  • 1
  • 5
  • 14
  • check that you don't have conflict in loading bootstrap.js files. because we used to write 'booster.widgets.TbGridView' not 'bootstrap.widgets.TbGridView'. so maybe you are loading two bootstrap libs – Abdulrazak Alkl Sep 10 '14 at 10:38
  • Hi, Can you use a css class instead of the id attribute? – Babak Bandpay Sep 10 '14 at 14:16

0 Answers0