the code below loads the datatable but when i detele the row from datatable the initial table does not reindex the rows how to resolve it?
function loadList() {
    var url_string = window.location.href;
    var url = new URL(url_string);
    var SampleAnalyzeId = url.searchParams.get("id");
    dataTable = $('#DT_load').DataTable({
        "ajax": {
            "url": "/api/SampleAnalyzeFile/" + SampleAnalyzeId,
            "type": "Get",
            "datatype": "json"
        },
        "columns": [
            { "data": "File", "width": "25%" },
            { "data": "FileName", "width": "10%" },
            { "data": "FileExtention", "width": "10%" },
            {
                "data": "Id",
                "render": function (data, type, row, meta) {
                    return <div class="text-center">
                                                                        <button class="btn btn-danger text-white" style="cursor:pointer;" type="button" onclick="DeleteRow(${meta.row})">حذف
                                                                            <i class="glyphicon glyphicon-trash"></i>
                                                                        </button>
                                                                    </div>;
                }, "width": "15%"
            }
        ],
        bLengthChange: false,
        paging: true,
        searching: false,
        ordering: true,
        "language": {
            //"emptyTable": "no Data Found"
            "url": "/js/PersianDataTable.json"
            //cdn.datatables.net/plug-ins/1.10.21/i18n/Persian.json
        },
        "width": "100%"
    });
}

function DeleteRow(rowIndex) {
    swal({
        title: "از حذف مطمئن هستید؟",
        // text: "این عملیات غیرقابل بازگردانی نخواهد بود.",
        icon: "warning",
        buttons: true,
        dangerMode: true
    }).then((willDelete) => {
        if (willDelete) {
            // Step 1: Remove the row from DataTable
            // var dataTable = $('#DT_load').DataTable();

            if (dataTable.rows().count() == 1) {
                console.log("data cleared")
                dataTable.rows().clear()
            }
            var deletedRow = dataTable.row(rowIndex).remove();
            //dataTable.rows().data().toArray()[rowIndex]["MineralMaterialId"];
            deletedRow.draw();
            dataTable.draw();

                // console.warn("uihdfhsdj")
            dataTable.rows().every(function (index) {
                var row = this.node(); 
                // $(row).find('td').eq(1).html(index)
                console.warn(row)
            }); // Ensure it updates the first cell with the new index });
                console.warn("uihdfhsdj  22222")

            var T = $('#DT_load').DataTable();
            // Collect remaining rows into an array
            let data = [];
            T.rows().every(function () {
                const rowData = this.data();
                data.push({
                    "File": rowData['File'],
                    "FileName": rowData['FileName'],
                    "FileExtention": rowData['FileExtention']
                });
            });
            console.warn(data)
            // Prepare the FormData object
            const formData = new FormData();
            formData.append("DataList", JSON.stringify({ list: data }));

            // Send the data to the server
            $.ajax({
                type: "POST",
                url: "?handler=Delete",
                data: formData,
                contentType: false,
                processData: false,
                headers: {
                    "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val()
                },
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("XSRF-TOKEN", $('input:hidden[name="__RequestVerificationToken"]').val());
                },
                success: function (response) {
                    // console.log("Data sent to server:", response);
                },
                error: function (error) {
                    console.error("Error in AJAX request:", error);
                }
            });
        }
    });