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

Is there better code generation for Yii2 other than Gii
Yii2: Registering javascript when loading (nested) Gridview through renderAjax
Yii2 set active user in API
Yii2 full calendar AjaxEvents not working properly
white color Issue after create thumbnail image in yii2
Creating a one-to-many relationship in Yii2
Handle Image update in yii2
Header and Footer missing in modal popup
Select2 Krajee widget - using modal and getting the id of the value
sjaakp/yii2-illustrated-behavior Yii2 extension for image not working
change the navigation bar url from yii2 without redirecting
Yii 2 - Conditional Assets?
How to get value of dropdown instead of id yii2
How can I access private value from object
How to add valueless attribute to <form> tag using yii2 ActiveForm
Register a js file independently in Assets

Categories

HOME
multithreading
pdf
variables
amazon-ec2
fluentd
plone
fme
objectgears
programming-languages
spring-jdbc
dxl
fsm
fingerprint
opengl-es-2.0
append
gorm
maude-system
tomcat6
apache-cayenne
flask-wtforms
dynamics-crm-online
clearcase-ucm
firefox-webextensions
textfield
custom-wordpress-pages
core-text
restful-authentication
h2db
shopware
sparse-matrix
su
info.plist
buck
windows-server-2000
google-cloud-nl
airconsole
pdb
karaf
google-sites-2016
copying
mmenu
http-digest
jquery-bootgrid
neuroscience
elasticsearch-plugin
dynamic-reports
arena-simulation
galleria
angular-resource
jsch
apache-fop
togetherjs
nstextview
recursive-datastructures
tactic
knpmenubundle
orthogonal
vmware-tools
elements
file-writing
underscore.js-templating
merge-conflict-resolution
player
lttng
nsviewcontroller
react-native-listview
make-install
bgp
rvest
ios8-today-widget
reactive-banana
lemon
collapse
metaclass
ibaction
inmobi
device-orientation
ng-animate
fluentautomation
valueconverter
srs
multiprocessor
ivyde
eventual-consistency
seed
free-variable
jquery-knob
wse3.0
doh
telerik-scheduler
sortable-tables
mirah
perfect-hash
database-management
kdbg
libs
port-number
private-members

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