-1

How can I get the Column id of a specific row cell index?

HTML table design : My Table

This code handles and Ajax request when the cell content of the table is dropped into another cell:

redipsInit = function () {
// reference to the REDIPS.drag lib
var rd = REDIPS.drag;
// initialization
rd.init();
// dragged elements can be placed to the empty cells only
rd.dropMode = 'single';
// define dropped handler
//the parameter targetCell is the reference of the cell where the content has been         
//dropped
rd.event.dropped = function (targetCell) {

    var tbl = rd.findParent('TABLE', targetCell); //reference to my table

    //getting the tabindex attribute that in my case represent the row index
    var cardPosition = targetCell.attributes[0].value;

    // the cell content (the div tag with class = "drag t1") has an ID that reprensents
    // the content ID in my DB.
    var cardIdBeingDragged = targetCell.firstElementChild.id;

    var columnID = "";
    var parametros = {
        "Card_Position": cardPosition,
        "Card_ID": cardIdBeingDragged,
        "Column_ID" : ??? // still dont know how to get it.
    };
    $.ajax({
        type: 'POST',
        url: "../../Contenido/Board.aspx/SaveCardPosition",
        data: JSON.stringify(parametros),
        contentType: "application/json; charset=utf-8",
        dataType: "json"
    });   
};
};

OK, I will make a scenario to understand what I want.

When a cell content is dropped from one cell to another i'm able to handle the javascript code that it is above.
The next step is to get 3 values parameters to send to my webMethod(SaveCardPosition) in code behind(ASP.Net)

I am able to get the:
CardId(Cell ContentId)
Rowindex where the targetCell belongs(Card_Position)

But I don't know how to get the column id where this targetCell belongs.

How can I achieve this?

Seth McClaine
  • 9,142
  • 6
  • 38
  • 64
Nahum Fabian
  • 180
  • 1
  • 2
  • 15

2 Answers2

0

I'd loop through the row and return an index when a given parameter matches the value, or any other attribute, of the cell you want, then you'd know what column it is and, therefore, it's column id.

Giovanni Di Toro
  • 797
  • 1
  • 14
  • 34
0

You could put data attributes in your cells specifying the column...

Seth McClaine
  • 9,142
  • 6
  • 38
  • 64
  • i could do it and its a great idea, but it doesnt fit my needs because if a colum cell doesnt have a card(Content) it means that the card doesnt exists in the DB so that cell content is blank. Its hard to explain, so that is why i want to know another alternative. – Nahum Fabian Jun 11 '13 at 04:18