내 데이터 목록에 대한 검색 모듈을 추가하려고합니다.
요청을 게시하는 내 함수는 뷰를 렌더링합니다.
검색 버튼을 누른 후 목록 그리드를로드하려면 어떻게해야합니까?
내가해야 코드 또는 뷰를 렌더링하고 그 위치에서 그보기를 쓰기?echo
html
나는 완전히 혼란스러워 ...
public function actionSell() {
$cond="";
if($_POST) {
foreach ($_POST as $key => $value) {
$_POST[$key] = str_replace(',', '', stripslashes(mysql_real_escape_string($value)));
}
$melk_id = $_POST['melk_id'];
$city_id = $_POST['city_id'];
$cost_from = $_POST['cost_from'];
$cost_to = $_POST['cost_to'];
$metraj_from = $_POST['metraj_from'];
$metraj_to = $_POST['metraj_to'];
if($melk_id) $cond .= ' and melk_id='.$melk_id;
if($city_id) $cond .= ' and city_id='.$city_id;
if($cost_from) $cond .= ' and cost >='.$cost_from;
if($cost_to) $cond .= ' and cost <='.$cost_to;
if($metraj_from) $cond .= ' and metraj >='.$metraj_from;
if($metraj_to) $cond .= ' and metraj <='.$metraj_to;
}
$dataProvider = new CActiveDataProvider('Data', array('criteria' => array(
'condition' => 'type = 0 '.$cond,
'order' => 'id DESC',
),
'pagination' => array('pageSize' => 15)
));
$this->render('sell', array(
'dataProvider' => $dataProvider,
));
}
나는 PHP 개발자는 아니지만 jQuery 방식으로 대답을 시도 할 것입니다.
컨테이너에 목록 그리드가 있다고 가정합니다. <div id="container"> //the grid </div>
그리드View
가 있는 컨테이너를 채 웁니다.
당신은이 Seach 텍스트 상자를
<input id="searchBox" type="text" name="SeachTxt" Value="Some text"/>
그리고 버튼 : <input id="SearchBtn" type="button" value="Search Now!">
다음으로 다음과 같은 jQuery ajax post 함수가 있어야합니다.
jQuery("#SearchBtn").click(function(e) {
e.preventDefault();
jQuery.ajax({
url: 'index.php?searchString=' + jQuery("#searchBox").val(),
success: function(result) {
jQuery("#container").html(result);
}
});
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다