I have two KendoGrids on my page and i want to bind values to KendoQRCode if some values are editing or was added
with input fields works it well, but i want to bind values from Grids after editing or after I add one more Phone to the Table
@(Html.Kendo().Grid(Model)
.Name(ProdGrid")
.Columns(columns =>
{
columns.Bound(p => p.Title);
columns.Bound(p => p.FirstName);
columns.Bound(p => p.MiddleName);
columns.Bound(p => p.FamilyName);
columns.Command(command => { command.Edit()});
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource.Ajax()
.Model(model =>
{
model.Id(p => p.ID);
})
.Read(read => read.Action(
"PDetails"
,
"Prod"
))
.Update(update => update.Action(
"EditingP"
,
"Card"
))
)
)
@(Html.Kendo().Grid(Model)
.Name(
"Phone"
)
.Columns(columns =>
{
columns.Bound(p => p.PhoneNumber);
columns.Command(command => { command.Edit().HtmlAttributes(
new
{ id = i +
"EditTel"
}); });
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.HtmlAttributes(
new
{ style =
"width:50%; float:left"
})
.DataSource(dataSource => dataSource.Ajax()
.Model(model =>
{
model.Id(p => p.ID);
})
.Create(update => update.Action(
"CreatePhone"
,
"Card"
,
new
{ id = @i }))
.Read(read => read.Action(
"CardPhone"
,
"Card"
))
.Update(update => update.Action(
"EditingPhone"
,
"Card"
,
new
{ id = @i }))
)
)
<div id=
"example"
>
<div
class
=
"configuration-horizontal"
id=
"qrConfig"
>
<div
class
=
"config-section"
>
<div>
<input id=
"qrPhone"
class
=
"k-textbox"
data-bind=
"value: qrPhone"
>
</div>
<br />
<div>
<textarea id=
"qrValue"
class
=
"k-textbox"
data-bind=
"value: qrValue"
rows=
"5"
cols=
"20"
></textarea>
</div>
</div>
<div
class
=
"config-section"
>
<span
class
=
"configHead"
>Options</span>
<ul
class
=
"options"
>
<li>
<label
for
=
"errorCorrection"
>Error correction level:</label>
<select id=
"errorCorrection"
data-role=
"dropdownlist"
data-bind=
"value: qrOptions.errorCorrection"
>
<option value=
"L"
>L</option>
<option value=
"M"
>M</option>
<option value=
"Q"
>Q</option>
<option value=
"H"
>H</option>
</select>
</li>
<li>
<label
for
=
"encoding"
>Encoding:</label>
<select id=
"encoding"
data-role=
"dropdownlist"
data-bind=
"value: qrOptions.encoding"
>
<option value=
"ISO_8859_1"
>ISO_8859_1</option>
<option value=
"UTF_8"
>UTF_8</option>
</select>
</li>
<li>
<label
for
=
"size"
>Size:</label>
<input id=
"size"
data-bind=
"value: qrOptions.size"
data-role=
"numerictextbox"
data-format=
"n0"
data-decimals=
"0"
/>
</li>
<li>
<label
for
=
"borderWidth"
>Border width:</label>
<input id=
"borderWidth"
data-bind=
"value: qrOptions.border.width"
data-role=
"numerictextbox"
data-format=
"n0"
data-decimals=
"0"
/>
</li>
</ul>
</div>
</div>
<script type=
"text/javascript"
>
$(document).ready(function () {
var qrCode = $(
"#qrCode"
).kendoQRCode({
size: 200
}).data(
"kendoQRCode"
);
var viewModel = kendo.observable({
qrPhone: 5454
qrValue:
"HaLo World"
,
qrOptions: {
errorCorrection:
"L"
,
encoding:
"ISO_8859_1"
,
background:
"#FFFFFF"
,
color:
"#000000"
,
size: 200,
border: {
color:
"#FFFFFF"
,
width: 0
}
},
setValue: function () {
qrCode.value(
this
.qrValue +
'\n'
+
this
.qrPhone:);
},
setElementWidth: function () {
qrCode.element.width(
this
.qrOptions.size);
}
});
viewModel.bind(
"change"
, function (e) {
if
(e.field ==
"qrPhone"
) {
this
.setValue();
}
if
(e.field ==
"qrValue"
) {
this
.setValue();
}
else
{
this
.setElementWidth();
qrCode.setOptions(
this
.qrOptions.toJSON());
}
});
kendo.bind($(
"#qrConfig"
), viewModel);
viewModel.setElementWidth();
viewModel.setValue();
});
</script>
with input fields works it well, but i want to bind values from Grids after editing or after I add one more Phone to the Table