I am using the select2 plugin Instead of dropdown to get multiple selected values Here is my code, I am using the select box to bring the data from query and also search the data and bring back the json response and fill the data in the select box.I have binded this select into clientside so i concatenate the count

Here is my code:

     <select style="width:100%;" id="cboolinkrelated' + count + '" class="chzn-container chzn-container-single span" multiple="multiple">

 $.ajax({

                                type: "POST",
                                url: 'api/Document/Gedocumentlink',
                                data: DocumentModel,
                                dataType: "json",
                                success: function (data) {

                                    debugger;

                                    for (var j = 1; j <= gridlength; j++) {
                                        $("#cboolinkrelated" + j + "").select2({
                                            quietMillis: 10,
                                            allowClear: true,
                                            placeholder: "Link to related"

                                        });

                                        $.each(data, function (key, value) {

                                            $("#cboolinkrelated" + j + "").append($("<option> </option>").val(value.AuditObjectSNo).html(value.AuditObject));
                                        });


                                },


                                error: function () {
                                    alert("Error");
                                }
                            });

click the save button & need the selected Value from cbolinkrelatedenter image description here

Related posts

Recent Viewed