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 make session works on all actions of one controller?
Yii2 display data from phpexcel in view before saving to database
yii2 dependant dropdown reset on edit action due to onchange function
Yii2 non-DB (or virtual) attribute isn't populated during massive assignment?
Yii2 Join multiple tables
Codeception Adding custom assert actions (functional testing)
Selected values in yii2
Yii queryBuilder; If dbexpression is not being quoted well
Time attribute validation in Yii2 framework
Yii2 kartik-datecontrol extension
SQL query help in Yii2
Yii2 Pjax inside ListView not working
how to get post value from multiple array in yii2
I want to display column data in Yii2 listview
Yii2 - How We can Change the element that Will be update via Pjax response
Yii2 error composer

Categories

HOME
keycloak
cookies
nullpointerexception
relative-path
platform-builder
tesseract
q
cmd
flyway4
paradox
python-unittest
vifm
resize
windows-azure-storage
timeout
jplayer
usergrid
event-handling
visual-studio-cordova
windows-server-2012
dynamics-crm-online
highlight.js
reactive-cocoa
http-status-code-504
database-replication
interop
introduction
accessor
mustache.php
uninstall
tooltipster
facebook-apps
large-file-upload
atlassian-crucible
newline
nouislider
calibre
hexo
hilbert-curve
unobtrusive-validation
hue
bootstrapper
broadcastreceiver
eigenvalue
http-redirect
.net-4.6.2
websphere-mq-fte
cubic-spline
taffy
promela
sage-one
winscp-net
gabor-filter
nstextview
tactic
diagnostics
kbuild
composite-key
media-player
ifs
pillow
mediaelement
instant
ado.net-entity-data-model
elements
paypal-express
storekit
websitepanel
testng-dataprovider
rtbkit
execute
cyclomatic-complexity
mutation-observers
fouc
myo
nsight
census
lustre
fscommand
html-helper
ceil
wp-query
typo3-neos
mbr
monomac
aqtime
quartz-graphics
ruby-datamapper
type-equivalence
http-unit
factory-method
referrer
e4x
browser-detection
libstdc++
javaspaces
uiviewanimation-curve
code-cleanup
window-management
inotifycollectionchanged
locate
paster
nsviewanimation
mirah
multi-tier
microsoft-virtualization
post-build
mdac
grid-system
data-acquisition

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