Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Implement on-click Autocomplete Value While Data Binding in Subgrid - How To?

    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 28
    Answer it
      $("#txtautocompid").autocomplete({
    
            source: function (request, response) {
                debugger;
                $.ajax({
    
                    url: '../WardManagement/WardResultEntry/autocomplete2',
                    //   url: '../WardManagement/WardResultEntry/DietAutocomp',
                    datatype: "json:",
                    data: {
                        Searchtext: $('#txtautocompid').val(),
                        searchText: request.term,
                        EatenHabbits: $('#txteatinghabits').val()
                    },
                    contentType: "application/json;charset=utf-8",
    //                dataFilter: function (data) { return data; },
                    success: function (data) {
    
                        if (data.length === 0) {
    
                        }
                        else {
                            response(data.slice(0, 10));
                        }
                    }
    
    
                });
            },
            minLength: 1,
            select: autodata
        });
        function autodata(e, ui) {
            debugger;
            $("#id1").val(ui.item.Menuid);
            $("#id2").val(ui.item.MenuName);
            $("#id3").val(ui.item.Rate);
            var a = $("#id1").val();
            var b = $("#id2").val();
            var c = $("#id3").val();
            var Menu_Name = $('#txtautocompid').val();
            var length_datatable = $("#subgrid").length;
            var aa = $("#doublesubgrid").dataTable().fnGetData();
            var  sub1 = $("#subgrid").dataTable().fnGetData();
            if (sub1 == ''||sub1!=''&&sub1 ) {
                var Resulet = 1;
                payt();
            }
            else {
                    var Result = 2;
              }
              if (Resulet == 1) {
               $("#subgrid").dataTable().fnAddData([a, b, c,
                 '<input type="image" id="can"  class="delete" href="#" src="../Content/img/cancel.png" style="height:25px;width:25px" />'
              ]);
               payt();
           }
           else if (Result == 2 )
                       
                {
                    for (var i = 0; i < sub1.length; i++) {
                      var daa = sub1[i][0];
    //                  if (daa == b) {s
               $("#doublesubgrid").dataTable().fnAddData([a, b, c,
                 '<input type="image"  id="can"  class="delete" href="#" src="../Content/img/cancel.png" style="height:25px;width:25px" />'
              ]);
               payt();
    //       }
       }
       
        }
       else if (Result == 2) {
           for (var i = 0; i < sub1.length; i++) {
               var daa = sub1[i][0];
               //                  if (daa == b) {s
               $("#doublesubgrid").dataTable().fnAddData([a, b, c,
                 '<input type="image"  id="can"  class="delete" href="#" src="../Content/img/cancel.png" style="height:25px;width:25px" />'
              ]);
               payt();
               //       }
           }
    
       }        
              
            }
            function payt() {
                $(a).val("");
                $(b).val("");
              
            }

    i am using two same subgrids

    condition is:

    if the autocomplete for example veg soup is clicked that corresponding data rate and and id should bind in first grid..if same veg soup is given again in autocomplete?(without refresh)that should come in next following second grid..if again apple i have given means that should come in first grid ..reapeated values should come in next second grid

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: