Yii 框架:这行 JQuery 代码是什么意思 [英] Yii framework: what does this JQuery line of code means

查看:15
本文介绍了Yii 框架:这行 JQuery 代码是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<块引用>

可能的重复:

  • http://code.google.com/p/zii/source/browse/trunk/widgets/assets/gridview/jquery.yiigridview.js?r=65
  • http://www.yiiframework.com/doc/api/1.1/CGridView
  • 抱歉,我对Yii框架不太了解,祝你好运!

    Possible Duplicate:
    Yii framework: Using data from related Active Record models for searching

    Yii provide advanced search functionality under admin page.

    This picture explain my question well.

    This functionality shown on the picture is carried out by following code sample.

    $('.search-form form').submit(function(){
        $.fn.yiiGridView.update('order-grid', {
            data: $(this).serialize()
        });
        return false;
    });
    

    There is a form with class attribute named search-form where we provide search criteria. Based on the search criteria, it update the grid view called order which is generated by following code sample.

    <?php $this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'order-grid',
        'dataProvider'=>$model->search(),
        'columns'=>array(
            'id',
            'order_create_date',
            'price',
            'bank_account_number',
            'hardwaredetail_Id',
            'user_id',
            'user.name',
            'user.email',
            ),
    } 
    

    Order table has a relationship with user table. i want to perform search functionality on user's name and email address. But Advanced search functionality Auto generate code only for search on order table. i am trying to customize advanced search to be able to search on relational data as well

    Thanks in advance for any help

    解决方案

    I'm not super sure what you're asking or if it's possible, but let me try and explain what is going on in your current code eample:

    $('.search-form form').submit(function(){
        $.fn.yiiGridView.update('order-grid', {
             data: $(this).serialize()
        });
        return false;
    });
    

    1. When you submit the form by hitting the search button jQuery stops the form from submitting.
    2. Instead, it will submit it using the $.fn.yiiGridView.update function.
    3. $(this).serialize() takes all of the data from the form and puts it into a format that's easy for the server to read.

    As for the other code sample it just creates the HTML for the form with an id of 'order-grid'.

    Now, on to what you're hoping to do instead. I've looked for some examples and docs about the $.fn.yiiGridView.update, which might be able to shed light on this. Here's what I've got:

    1. http://tech.ldg.me/yii-php-framework-snippets
    2. http://code.google.com/p/zii/source/browse/trunk/widgets/assets/gridview/jquery.yiigridview.js?r=65
    3. http://www.yiiframework.com/doc/api/1.1/CGridView

    Sorry, I don't know more about the Yii framework and good luck!

    这篇关于Yii 框架:这行 JQuery 代码是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆