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

Integration Reportico in Yii2 Projects
Yii2 : Subdirectory in yii2 not working
Yii2 KCFinder with CKEditor
Yii2 - validation compare acting strange
Updating composer throws exception Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist
Dynamic declaration of a model in Yii2
image are save in folder but not saved in database in yii2.0
how can i put sidebar menu in right side using yii2
Yii2 afterSave. Using changedAttributes show error
how to do a nested foreach loop in yii2?
Yii2, Set multiple Value Select2
update single field directly gave value in update function yii2
How can i use multi controller in one page?
PHP Composer “require” OR condition with version in future
Yii2 DropdownList on relationated tables
How to install the new version of Redactor Imperavi?

Categories

HOME
client
clips
ngrx
iot
syntax
fme
android-4.4-kitkat
getelementsbytagname
leon
infragistics
rdf
electronics
google-project-tango
baqend
elasticsearch-hadoop
fancybox-3
jplayer
caml
contextmenu
reverse-proxy
ml
clickonce
scriptcs
functional-testing
arabic
css-animations
kvc
core-text
java-7
emgucv
one-to-many
sparse-matrix
internet-explorer-9
ejabberd-module
subdomains
pdb
mozilla
force-layout
mapdb
host
git-merge
retina-display
hockeyapp
objectlistview
hilbert-curve
xenforo
webix-treetable
squib
texmaker
arena-simulation
auto-update
blogengine.net
csound
account-kit
gnome-shell-extensions
passport-google-oauth
radtreelist
database-optimization
asp.net-4.5
fuzzy-search
flash-cs5
hill-climbing
pickadate
goose
xpath-1.0
srand
jmeter-maven-plugin
content-length
coveralls
arcanist
mono-embedding
pretty-print
dereference
notify
e10s
device-orientation
codeigniter-url
winddk
asp.net-dynamic-data
mdt
codeigniter-routing
preferences
rdl
zend-route
has-many-through
picturefill
cloud-connect
srs
centos5
industrial
html4
ember-app-kit
jelly
gdata-api
frameset
online-compilation
osql
postgresql-performance
transactionscope
adk
coredump
coercion
horizontal-accordion
recent-documents
locate
lpeg
digest-authentication
getresponsestream
modelstate
iweb
pascal-fc
windows-live-messenger
lzh

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