public IActionResult GetAssetsTree(AssetDataModel Parent_ID, AuditIdRow row,string workspaceId){
_assetService.CollectionName = workspaceId;
_assetService.ParentId = workspaceId;
return(Json(CreateTree(null,null)));
}
CreateTree calls me to a private method
private AuditIdRow CreateTree(AssetDataModel Parent, AuditIdRow row){
return row;
}
AuditIdRow Class
public class AuditIdRow : BaseModel
{
public string Name {get;set;}
public bool IsGroup{get;set;}
public List<AuditIdRow> Children { get; set; }
}
Vista html:
<div class="modal fade" id="modal-container-root" tabindex="1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4>Selecciona tu código de acción para trabajar</h4>
</div>
<div class="modal-body">
<div class="list-group" id="TreeGroups" role="tablist">
//Aqui es donde quiero cargar los datos
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
Javascript function to load the modal:
<script>
$(document).ready(function () {
$.get("GetAssetsTree") // llamo al método para que me devuelva los datos
.done(function (data){
$.each(data,function(index,obj){
$("#TreeGroups").append('<option value="'+obj.Name+'">'+obj.row.+'</option>');
});
})
.fail(function(data){
alert(data);
} )
});
</script>
I want to fill in the modal with the data that comes from the getAssetTree method, where I want to show the name of AuditIdRow first, and inside it to show me the list of children to make a TreeView view within the modal.