我将创建yii2分页并且我有以下代码,但是它给出了一个错误,比如调用非对象上的成员函数offset()
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RatingBar;
import com.github.gcacace.signaturepad.views.SignaturePad;
import com.oviyum.fleetfoot.R;
/**
* A simple {@link Fragment} subclass.
*/
public class SignatureFragment extends Fragment implements View.OnClickListener {
private Activity activity;
private Context context;
private View view;
private SignaturePad signaturePad;
private Button uploadSignature;
private Button resendOTP;
private Button submit;
private RatingBar ratingBar;
public SignatureFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_signature, container, false);
init();
return view;
}
private void init() {
signaturePad = (SignaturePad) view.findViewById(R.id.handover_signature_signature_pad);
uploadSignature = (Button) view.findViewById(R.id.handover_signature_upload_signature);
uploadSignature.setOnClickListener(this);
resendOTP = (Button) view.findViewById(R.id.handover_signature_resend_otp);
resendOTP.setOnClickListener(this);
ratingBar = (RatingBar) view.findViewById(R.id.handover_signature_experience);
submit = (Button) view.findViewById(R.id.handover_signature_submit);
submit.setOnClickListener(this);
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
this.context = context;
this.activity = getActivity();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.handover_signature_upload_signature:
break;
case R.id.handover_signature_resend_otp:
break;
case R.id.handover_signature_submit:
break;
}
}
}
答案 0 :(得分:0)
通常由gii创建并基于ModelSearch模式的模型通常是分页 已经可以通过defualt完成所有必需的参数
最终你可以更改页面大小或配置其他参数
public function actionIndex() {
$searchModel = new UsermasterSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->query->andWhere( 'user_id 1']);
// eventually you can change the page sise
$dataProvider->pagination->pageSize=5;
return $this->render('index', ['searchModel' => $searchModel,'dataProvider' => $dataProvider,]);
}
在你的代码中有两个$ dataProvider的定义(我不知道第二个是否是一个有效的数据提供者)你可以避免这只是改变查询属性,例如:添加和到$ dataProvider