'Table with out text .Net6 + Knockout.js + DataTables.net

When page load then fill this:

 <select class="form-control" 
        data-bind="options: UsersList,
                optionsText: function(item) {
                    return item.name()
                },
                value: selectedUser"></select>
 

then select one of the user and

 self.loadADGroups = () => {
        self.selectedUser().ActiveDirectoryUserGroupList.removeAll();
        let getParams = {
            distinguishedName: self.selectedUser().ident()
        };

        $.ajax({
            method: 'GET',
            url: ActiveDirectoryGroupsListUrl,
            data: getParams,
            success: (responseData) => {
                responseData.forEach((o, i, a) => {
                    var vm = getActiveDirectoryGroupViewModel(o);
                    self.selectedUser().ActiveDirectoryUserGroupList.push(vm);
                });
            },
            error: () => {
            }
        });
    }

Html table :

<div id="ReportActiveDirectoryGroupUser" data-bind="with: selectedUser() ">
    <table id="ReportTableActiveDirectoryGroupUser"  style="width:100%">
        <thead>
            <tr>
                <th>Nazwa grupy w AD</th>
                <th>Opis grupy w AD</th>
            </tr>
        </thead>
        <tbody data-bind="foreach: ActiveDirectoryUserGroupList">
            <tr>
                <td><span data-bind="text: AdName"></span></td>
                <td><span data-bind="text: Addecsription"></span></td>
            </tr>
        </tbody>
    </table>

</div>

The table has the same number of rows as the model returned from the controller, but there is no data in them and there are in the model



Solution 1:[1]

The return model has AdName, AdDescription—but in responsedata, there was adName, adDescription.

getActiveDirectoryGroupViewModel = (apiResponseObject) => {
    var result = new ActiveDirectoryGroupViewModel();

    result.AdName(apiResponseObject.adName);
    result.Addecsription(apiResponseObject.addecsription);

    return result;
}

This work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeremy Caney