Yii框架:此JQuery代码行意味着什么 [英] Yii framework: what does this JQuery line of code means

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

问题描述

可能重复:
Yii框架:使用来自相关Active Record模型的数据用于搜索

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

Yii在管理页面下提供了高级搜索功能.

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;
});

有一个名为search-form的类属性的表单,我们在其中提供搜索条件.根据搜索条件,它将更新由以下代码示例生成的称为订单的网格视图.

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

预先感谢您的帮助

推荐答案

我不太确定您要问的内容或是否可能,但是让我尝试解释一下当前代码示例中发生的情况:

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. 当您点击搜索按钮提交表单时,jQuery会阻止表单提交.
  2. 相反,它将使用$ .fn.yiiGridView.update函数提交它.
  3. $(this).serialize()从表单中获取所有数据,并将其放入服务器易于读取的格式.

对于其他代码示例,它只是为ID为'order-grid'的表单创建HTML.

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

现在,继续执行您希望执行的操作.我寻找了一些有关$.fn.yiiGridView.update的示例和文档,它们也许可以阐明这一点.这就是我所拥有的:

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
  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

对不起,我对Yii框架了解不多,祝您好运!

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

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

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