gijgo icon indicating copy to clipboard operation
gijgo copied to clipboard

cannot read properties of undefined (reading 'children)

Open prasenjitatwork opened this issue 4 years ago • 0 comments

creating an application in .Net Core 5. using gijgo grid with reference https://gijgo.com/LiveEdit/Index/bootstrap-grid-inline-edit.html?component=grid#

but getting error "cannot read properties of undefined (reading 'children)" Datasource code: public async Task<IActionResult> GetAll1() { List<Company> CompanyList = new List<Company>(); using (var httpClient = new HttpClient()) { using (var response = await httpClient.GetAsync("http://localhost:28605/api/Company")) { string apiResponse = await response.Content.ReadAsStringAsync(); CompanyList = JsonConvert.DeserializeObject<List<Company>>(apiResponse); } } return Json(new { status = "success", records = CompanyList.ToList() }); }

Html Code: `

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12">
            <table id="grid"></table>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var grid, countries;
        grid = $('#grid').grid({
          /*  dataSource: '/Home/GetAll1',*/
            dataSource: '@Html.Raw(@Url.Action("GetAll1", "Home"))',
            uiLibrary: 'bootstrap4',
            primaryKey: 'CompanyId',
            ContentType: 'application/json',
            inlineEditing: { mode: 'command' },
            columns: [
                { field: 'CompanyId', width: 44 },
                { field: 'CompanyName', editor: true },
                { field: 'CompanyDetails', editor: true },
                //{ field: 'CountryName', title: 'Nationality', type: 'dropdown', editField: 'CountryID', editor: { dataSource: '/Locations/GetCountries', valueField: 'id' } },
                //{ field: 'DateOfBirth', type: 'date', editor: true },
                { field: 'isActive', title: 'Active?', type: 'checkbox', editor: true, width: 90, align: 'center' }
            ],
            pager: { limit: 5 }
        });

         grid.on('rowDataChanged', function (e, id, record) {
            // Clone the record in new object where you can format the data to format that is supported by the backend.
            var data = $.extend(true, {}, record);
            // Format the date to format that is supported by the backend.
            data.DateOfBirth = gj.core.parseDate(record.DateOfBirth, 'mm/dd/yyyy').toISOString();
            // Post the data to the server
            $.ajax({ url: '/Players/Save', data: { record: data }, method: 'POST' })
                .fail(function () {
                    alert('Failed to save.');
                });
        });
        grid.on('rowRemoving', function (e, $row, id, record) {
            if (confirm('Are you sure?')) {
                $.ajax({ url: '/Players/Delete', data: { id: id }, method: 'POST' })
                    .done(function () {
                        grid.reload();
                    })
                    .fail(function () {
                        alert('Failed to delete.');
                    });
            }
        });
    });
</script>`

api return data perfectly but get the error "cannot read properties of undefined (reading 'children)"

prasenjitatwork avatar Oct 01 '21 06:10 prasenjitatwork