Ajax - serverside - Buttons

Ajax - serverside - Buttons

typhontyphon Posts: 25Questions: 7Answers: 0

Hello,

my table is showing tasks for technicians. Every row represents a task.

I'm try using the ajax option. It's working very well if i have only text in the columns. But in my rows I've some Buttons (Show -> Opens a new href with detail information another button opens the workflow modal to send and accept tasks from another user).

My html

<tr class="odd" role="row">
     <td>...</td>
     <td>...</td>
     <td class="sorting_1">...</td>
     <td class="">...</td>
     <td>05.03.2015, 06:07</td>
     <td>...</td>
     <td>...</td>
      <td>-</td>
     <td>
       <button id="workflowBtn" class="btn btn-success workflow btn-padding" data-id="37005"><span class="glyphicon glyphicon-transfer" aria-hidden="true">  </span></button>
     </td>
     <td>
       <a class="btn btn-default" target="_blank" href="http://..."><span class="glyphicon glyphicon-tags" aria-hidden="true"></span></a>
     </td>
     <td>
       <a class="btn btn-default" target="_blank" href="....."><span class="glyphicon glyphicon-book" aria-hidden="true"></span></a>
     </td>
     <td>
       <a class="btn btn-info" href="/Task/ShowTask/37005"><span class="glyphicon glyphicon-search" aria-hidden="true"></span> Details</a>
     </td>
                             
     </tr>
<tr class="odd"><td></td><td colspan="11">....</td></tr>

My controller returns (the last 4 "" are the buttons..):

return Json(new
            {
                draw = param.draw,
                recordsTotal = nonfilteredcount,
                recordsFiltered = filteredCount,
                data = taskList.ToList()
                .Select(r => new[] {
                    r.Task.Text,
                       r.Task.Tid,
                       r.Task.Subject,
                       r.Terminal.Address.ToString(),
                       r.Task.RemindDate + "",
                       r.State,
                       r.Task.ServiceID + "",
                       r.LastTimeRecord + "",
                       "",
                       "",
                       "",
                       ""
                      
                   }
                )
            }, JsonRequestBehavior.AllowGet);

How can I redraw the buttons with Json? Is there maybe a solution?

Thx a lot and BR

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,839Questions: 1Answers: 10,518 Site admin
    Answer ✓

    There are basically two options:

    1. columns.defaultContent which you can use if the buttons in each row are identical and whatever action they need to take is controlled by a Javascript event handler. You can see an example of that here.
    2. columns.render which you can use if the buttons need to be different in each row - e.g. a real link. The documentation for renderers is available here.

    Allan

This discussion has been closed.