Skip to content

How to add new empty row to table based on dropdown id using

suman goud

Asked Sep 29, 2016, 2:34 AM EDT1 answer
Share
LinkedInX
When customer(dropdown) is selected am binding pending value and amount of that customer in two texboxes.
i given +(Add) to add new row to bind another customer details, am able to add new row, but in that added row same first selected
values are binding and if i change dropdown in second row,both 2 rows values are changing .
i have tried using for loop but am not getting ,
ReceiptsViewModel is to retrie data from multiple tables
Customer
Pendings
Amount
Select Customer
JS
JavaScript
$scope.rvm = [{}];
$scope.GetAccountBalance = function (index, c) {
    var getPendingData = ReceiptsService.GetPendings(c);
    getPendingData.then(function (d) {
        $scope.ReceiptsViewModel = d.data;
    }, function (error) {
        alert('Error');
    });

    //for (x in d.data) {
    //    if (d.data.Party == c) {
    //        var newdata = d.data;
    //        $scope.ReceiptsViewModel[x] = newdata;
    //    }
    // }

    //adding row on plus click
    $scope.addRow = function (index, c) {
        if ($scope.rvm.length == (index + 1)) {
            $scope.rvm.push({
            });
        }
    }
    $scope.deleteRow = function ($index) {
        $scope.rvm.splice($index, 1);
    }
}




        public JsonResult GetPendings(int? pendingID)
        {
            string eid = pendingID.ToString();
            TestDemoEntities db = new TestDemoEntities();
            var data = (from ap in db.Accounting_PendingBills
                        join apa in db.Accounting_PendingBillsAdjusted on ap.BillRef equals apa.TowardsBillRef
                        group apa by new { ap.BillDate, ap.Amount, ap.Party, apa.TowardsBillRef } into g
                        select new
                        {
                            Amount = g.Key.Amount,
                            Pendings= g.Sum(aa => aa. Pendings)
                        }).Where(ap => ap.Party == eid).FirstOrDefault();
                     //  }).Where(ap => ap.Party == eid).ToList();

            return Json(data, JsonRequestBehavior.AllowGet);
        }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Delpin Susai Raj
    0
    JavaScript
     var isClone = false;  lastRowInputs.each(function() { if($(this).val().length) {        isClone = true; } }); if(!isClone) return false;
    0