We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to map index using jquery to repair indexes when remove

Thread ID:

Created:

Updated:

Platform:

Replies:

126010 Sep 18,2016 01:48 AM UTC Sep 20,2016 01:21 PM UTC ASP.NET MVC 1
loading
Tags: General
ahmedsa
Asked On September 18, 2016 01:48 AM UTC

Problem
when remove any course from table list html his position in center or first it make problem

in index in database

Details

IF I have list of courses as following :

Delphi

Flash

Photoshop

IF I remove flash by JQUERY remove button then click save button

it delete flash and Photoshop

because there are wrong in delete courses by using remove function in jquery

if i remove php it is working without any problem because it is last item

suggestion

using map function when remove but how to do that

if there are any solution for that without using map no problem

i use model as following

public class Cusomemp2 

{

public List<EmployeeCourse> empcourses { get; set; }



}

}

i use for edit httppost

var result = db.Employees 

.Where(p => p.Id == custom.Id)

.Include(c => c.EmployeeCourses)

.FirstOrDefault();

if (custom.empcourses.Any())

{

foreach (var ec in result.EmployeeCourses.ToList())//to remove existing EmployeeCourses

{

db
.EmployeeCourses.Remove(ec);

db
.SaveChanges();



}

}



result
.EmployeeCourses = custom.empcourses;

db
.SaveChanges();


in model view my code as following by jquery

actually i need to modify code below using map function if there are any function do that never mind
$(function () { 

//add courses using drop down

var index = 0;

$
("#CourseId").change(function () {



var id = $(this).val();

var txt = $("#CourseId option:selected").text();



$
("#tb").append("" + txt + "")



index
++;



});

$
("#tb").on("click", ".r", function () {

// remove function

$
(this).parent().parent().remove();



$
(this).parent().prev().prev().remove();

});



// retrieve data in edit view using ajax

$
.ajax({

url
: "/Employee/getcoursesbyempid",

data
:{x:$("#hid").val()},

success
: function (res) {

$
.each(res, function (i, e) {



$
("#tb").append("" + e.CourseName + "")



index
++;

});

}



})

});

to see what i need found in this image
http://www.mediafire.com/view/lnuwcig5dxu6ctv/wrong_index.jpg


Attachment: wrong_index_584ed073.rar

Dhivyalakshmi Thirumurugan [Syncfusion]
Replied On September 20, 2016 01:21 PM UTC

Hi Ahmedsa, 

Thanks for contacting Syncfusion support. 

We have prepared sample as per your requirement. Please find the sample link below. 


Please get back to us if you have any queries related to Syncfusion components. 

Regards, 
Dhivyalakshmi. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;