This is a migrated thread and some comments may be shown as answers.

Change barcode encoding at runtime in a template

1 Answer 32 Views
Barcode
This is a migrated thread and some comments may be shown as answers.
Menashay
Top achievements
Rank 1
Menashay asked on 20 Jun 2014, 03:52 AM
How would you change the barcode encoding at runtime if the barcode widget is used in a template?
To clarify, user selects barcode type from a dropdown list, according to selection the barcode changes.
The barcode widget is used in a listview as a template.
For example, in the listView -
@(Html.Kendo().ListView()
    .Name("listView')
    .ClientTemplateId("aTemplate")
    :
    :
)

<script type="text/x-kendo-tmpl" id="aTemplate">
        <div class="product">
            <h3>#:ProductTitle#</h3>           
            @(Html.Kendo().Barcode()
                .Name("Id_#=Id#")
                .Value("#=Barcode#")
                .Encoding(BarcodeSymbology.Code128)       <-- how whould you change this at runtime?
                .Height(50)
                .Width(180)               
                .ToClientTemplate()
            )       
         </div>
 </script>

Regards,
Menashay

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 24 Jun 2014, 05:49 AM
Hi Menashay,

This could be achieved by subscribing to the change event of the DropDownList. Once the event is triggered, get the instance of the Barcode and use the setOptions method to apply the new encoding, then redraw the widget. For example: 
var barcode = $("#Id_123456").getKendoBarcode();
barcode.setOptions({type: this.value()}); //taken from the DropDownList's value method
barcode.redraw();

Regards,
Alexander Popov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Barcode
Asked by
Menashay
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or