yii2


Yii2 karthik editable column first row not working


I used karthik grid view and editable column to edit my grid view data. it not work for the first row of the grid view and work for the other rows when i enter value to the first row it give error like this
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
my gridview code is.
<?= GridView::widget([
'dataProvider' => $dataProvider,
'pjax' => true,
'pjaxSettings' => [
'options' => [
'id' => 'grid',
]
],
'export'=>false,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'header'=>'Sub Category',
'value'=>'item.subCategory.name',
],
'item.code',
[
'header'=>'Brand',
'value'=>'item.brand.name',
],
'item.description',
'item.pack_size',
[
'header'=>'Unit',
'value'=>'item.unit',
],
[
'header'=>'Last Price',
'value'=>function($model){
$customerId = $model->customerOrderRequest->customer_id;
$lastPurchasedPrice = Item::getLastPurchasedPrice($customerId,$model->item_id);
return '$ ' . number_format($lastPurchasedPrice, 2);
}
],
[
'class' => 'kartik\grid\EditableColumn',
'attribute'=>'qty',
'editableOptions' =>
[
'formOptions' => ['action' => 'customer-order-request']
],
'header' => 'Qty',
],
[
'header'=>'Estimate',
'value'=>function($model)
{
return '123123.00';
}
],
[
'header'=>'Price (UNIT)',
'format'=>'raw',
'value'=>function($modal){
$salse_rep_id = Yii::$app->user->identity->ref_id;
$exsist_respond = Respond::find()->where(['sales_rep_id'=>$salse_rep_id,'customer_order_request_id'=>$modal->customer_order_request_id])->one();
if(!empty($exsist_respond)){
$exsist_respond_item = RespondItem::find()->where(['item_id'=>$modal->item_id,'respond_id'=>$exsist_respond->id])->one();
if(!empty($exsist_respond_item)){
$price = $exsist_respond_item->price;
} else {
$price = NULL;
}
} else {
$price = NULL;
}
if(!empty($exsist_respond) && $exsist_respond->status !="Pending"){
return $price;
}else{
return "<input type='text' class='respond-item' cor='$modal->customer_order_request_id' value='$price' item_id='$modal->item_id' />";
}
},
'visible'=>(Yii::$app->user->identity->ref_table =="sales_rep")? true:false
],
],
]); ?>
and my controller is
public function actionEditable()
{
if (Yii::$app->request->post('hasEditable'))
{
$customerItemsId = Yii::$app->request->post('editableKey');
print_r($customerItemsId);die();
$model = RequestItem::findOne($customerItemsId);
$out = Json::encode(['output'=>'', 'message'=>'']);
$post = [];
$posted = current($_POST['RequestItem']);
$post['RequestItem'] = $posted;
if ($model->load($post))
{
$model->save();
$output = '';
$out = Json::encode(['output'=>$output, 'message'=>'']);
}
echo $out;
return;
}
}
any one can help me with this problem.
Form tag nested.
a trick: Add a fake form to let browser remove it.
I meet this problem today, cause I put a form in another, they are nested.
So the browser remove the first nested form.
In the official W3C XHTML specification, Section B. "Element Prohibitions", states that:
"form must not contain other form elements."
official website

Related Links

Yii2: Create path and url for folder inside a module
Disable ActiveForm Clientside Validation on button other than submit Yii2
CRUD view link does not work in Yii2
Yii2 DynamicForm: Demo 3: Nested Dynamic Form with types of rooms
Company Follow Button disappear after login popup - Linkedin issue
How do I get rid of composer-asset-plugin in yii2
Yii2 Can not Store huge integer
Yii2 flash messages rendered automatically
Foreign Keys in yii2.0
ActiveForm doesn't submitting after clicking submit Yii2
Does Yii2 AR class can check, does two objects has a link?
Yii2 dependent DropdownList State and City
Add more action in yii2 grid-actionColumn
yii2 “urlmanager” rules “conflict” issue?
In Yii2 Kartik Select2 widget how to make an ajax call on select event?
Yii2 ActiveRecord add a new record with unique text field

Categories

HOME
openmp
minimum-spanning-tree
nullpointerexception
view
hashmap
electron
vmware
framework7
spring-jdbc
survey
ip
cross-browser
convolution
indesign
upload
webrequest
synchronization
imacros
messages
visual-studio-cordova
code-review
openedx
orleans
wkwebview
language-agnostic
wijmo
microsoft-sync-framework
selectedindexchanged
internet-explorer-9
linkerd
elasticsearch-ruby
xacml
key-value-observing
http-status-code-503
siesta-swift
copying
typed.js
protovis
atl
force-layout
nssegmentedcontrol
simplexml
multilingual
cookiecutter-django
nand2tetris
spring-security-kerberos
arena-simulation
eclipse-gef
angular2-meteor
taffy
jquery-nestable
capacity
minimization
google-cdn
objective-c-swift-bridge
medium.com
gridpane
measures
etsy
ubuntu-10.04
uid
ruby-2.2
atk4
dukescript
browser-bugs
camanjs
tablelayout
fpml
responsive-slides
wp-query
valueconverter
expected-exception
mechanize-ruby
oracle-warehouse-builder
ivyde
ccss
tws
jquery-mobile-dialog
mqx
google-email-migration
datawindow
osql
vdsp
subgurim-maps
appender
inotifycollectionchanged
compiler-specific
project-hosting
rtml

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App