You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

点击“Closed: Cancelled”按钮后同步状态至经办人列的技术问题

Hey there! Let's tackle this issue together. It sounds like when you click the "Closed: Cancelled" button, you want the assignee column in the same table row to update to show that status too, right? Here's how you can fix that:

Fixing the Assignee Column Update on Cancel Button Click

First, let's ground this in your existing table structure. Based on your snippet, I'll assume your table rows look something like this (filling in the missing pieces):

<tr data-ticket-id="123">
  <td class="assignee">John Doe</td>
  <!-- Other ticket columns (status, date, etc.) -->
  <td>
    <button class="cancel-btn">Closed: Cancelled</button>
  </td>
</tr>

Step 1: Add a Click Listener to Sync the Assignee Column

You'll need to listen for clicks on the cancel button, then traverse the DOM to find the corresponding assignee cell in the same row. Here's how to do it with vanilla JavaScript:

// Grab all cancel buttons on the page
const cancelButtons = document.querySelectorAll('.cancel-btn');

cancelButtons.forEach(button => {
  button.addEventListener('click', function() {
    // 1. Find the parent table row of the clicked button
    const parentRow = this.closest('tr');
    
    // 2. Locate the assignee cell in this row (adjust the class to match your actual HTML)
    const assigneeCell = parentRow.querySelector('.assignee');
    
    // 3. Update the assignee cell to show the cancelled status
    if (assigneeCell) {
      assigneeCell.textContent = 'Closed: Cancelled';
      // Optional: Add styling for visual feedback
      assigneeCell.classList.add('cancelled-status');
    }

    // Optional: If you need to persist this change to the backend (so it stays after refresh), add a fetch request here
    // const ticketId = parentRow.dataset.ticketId;
    // fetch(`/api/tickets/${ticketId}/cancel`, { method: 'POST' })
    //   .then(res => res.json())
    //   .then(data => console.log('Ticket cancelled successfully:', data));
  });
});

If You're Using jQuery

If jQuery is part of your stack, the code is a bit more concise:

$('.cancel-btn').on('click', function() {
  const $row = $(this).closest('tr');
  $row.find('.assignee').text('Closed: Cancelled').addClass('cancelled-status');
  
  // Optional backend sync:
  // const ticketId = $row.data('ticket-id');
  // $.post(`/api/tickets/${ticketId}/cancel`, function(response) {
  //   console.log('Backend updated:', response);
  // });
});

Quick Checks to Avoid Issues:

  • Double-check that your class selectors (.assignee, .cancel-btn) match exactly what's in your HTML. If you're using IDs instead, adjust the selectors accordingly.
  • If your button already triggers backend logic, make sure to update the assignee column after the backend request succeeds (in the .then() block for fetch, or the success callback for jQuery) to keep frontend and backend in sync.
  • Adding a CSS class like cancelled-status can help highlight the changed state (e.g., gray text, strikethrough, or a light background).

内容的提问来源于stack exchange,提问作者Andre F

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:19:02