我正在尝试使用kartik gridview并出现以下错误。 -
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns,
'showPageSummary' => true,
'columns' => [
['class' => 'kartik\grid\SerialColumn'],
[
'attribute'=>'s_period',
'filter'=>ArrayHelper::map(Salary::find()->asArray()->all(), 's_period', 's_period'),
],
's_empid',
's_empname',
[
'attribute'=>'s_epf',
'pageSummary'=>true
],
//['class' => 'yii\grid\ActionColumn'],
],
]); ?>
我已经检查过了 - Yii2: Kartik Gridview sum of a column in footer。但是我的代码中没有找到问题。
index.php代码 -
import UIKit
class FirstViewController: UIViewController {
@IBOutlet weak var siteNameLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var siteName = ""
let requestURL: NSURL = NSURL(string: "http://wheretogo.com.mx/backends/service.php")!
let urlRequest: NSMutableURLRequest = NSMutableURLRequest(URL: requestURL)
let session = NSURLSession.sharedSession()
let task = session.dataTaskWithRequest(urlRequest) {
(data, response, error) -> Void in
let httpResponse = response as! NSHTTPURLResponse
let statusCode = httpResponse.statusCode
if (statusCode == 200) {
//print("Everyone is fine, file downloaded successfully.")
do{
let json = try NSJSONSerialization.JSONObjectWithData(data!, options:.AllowFragments)
if let appInfo = json["appInfo"] as? [[String: AnyObject]] {
siteName = appInfo[0]["siteName"] as! String
self.siteNameLabel.text = siteName
}
}catch {
print("Error with Json: \(error)")
}
}
}
task.resume()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
答案 0 :(得分:1)
如果手动分配列,则不需要变量列规范,因此将其删除
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
//'columns' => $gridColumns,
'showPageSummary' => true,
'columns' => [
['class' => 'kartik\grid\SerialColumn'],
[
'attribute'=>'s_period',
'filter'=>ArrayHelper::map(Salary::find()->asArray()->all(), 's_period', 's_period'),
],
's_empid',
's_empname',
[
'attribute'=>'s_epf',
'pageSummary'=>true
],
//['class' => 'yii\grid\ActionColumn'],
],
]); ?>