2015-04-03 89 views
1

我正在使用Yii 1.1.15框架。Yii CGridView搜索「&」包含屬性

我無法搜索&作爲查詢字符串中屬性(例如brand_name)中的符號。如果我進入&符號的URL看起來像這樣:

localhost/doctors/brand/?brand[brand_name]=&&brand[brand_status]= 

這裏的情況是brand[brand_name]=&。它不考慮&並將其作爲下一個參數終止,如果我只編碼該字符,它將變爲:%26因此url變爲localhost/doctors/brand/?brand[brand_name]=%26&brand[brand_status]=並且它會給出正確的結果。

但如何編碼yii CGridView過濾文本數據?

在此先感謝。

+0

語法和formattation – Michael 2015-04-03 13:02:25

回答

0

CGridView使用GET作爲默認ajax類型,&是http請求GET參數的分隔符,因此您不能將此字符用作搜索字符串的一部分。我認爲解決方案是使用POST而不是GET來處理Ajax請求。對於從GET改變CGridView阿賈克斯參數POST,添加'ajaxType' => "POST"您cgridview選項:

<?php $this->widget('zii.widgets.grid.CGridView', array(
     'id'=>'...', 
     'ajaxType' => "POST", 
     'dataProvider'=>$model->search(), 
     'filter'=>$model, 
     'columns'=>array(
     ... 
     ), 
)); ?> 
+0

我tryed,但它不工作,我習慣也「enableHistory」 =>真實的,你可以給一個expample 。 – 2015-04-04 10:18:45

+0

你確定嗎?!我在我的CGridView中測試它,它工作正常。我輸入'&'作爲搜索過濾器,並且網格毫無問題地將它發送到行動中! – hamed 2015-04-04 10:21:36