TH in Semantic Datatable inside tab width is not set - css

How to make tag is width to 100% in Semantic css with datatable inside tab.
Currently I have 3 tab with 1 datatable each, width is only set on Tab1 but not in Tab2 and Tab3
Here is my code: 1. HTML
<div class="ui top attached tabular menu">
<a data-toggle="tab" class="item active" data-tab="first">Other Hardwares Relation</a>
<a data-toggle="tab" class="item" data-tab="second">Software and License Relation</a>
<a data-toggle="tab" class="item" data-tab="third">Document Relation</a>
</div>
<div class="ui bottom attached tab segment active" data-tab="first">
<table class="ui celled table display nowrap" style="width:100%" datatable>
...
</table>
</div>
<div class="ui bottom attached tab segment" data-tab="second">
<table class="ui celled table display nowrap" style="width:100%" datatable>
<thead>
<tr>
<th>No.</th>
<th>Software #</th>
...
</tr>
</thead>
<tbody>
#foreach ($softwares as $index=>$software)
<tr>
<td>{{ $index+1 }}</td>
<td>{{$software->code}}</td>
...
</tr>
#endforeach
</tbody>
</table>
</div>
<div class="ui bottom attached tab segment" data-tab="third">
<table class="ui celled table display nowrap" style="width:100%" datatable>
...
</table>
</div>
</div>
and 2. JS
<script>
$(document).ready(function() {
$('[datatable]').DataTable({
"scrollX": true,
"paging": false,
"searching": false,
dom: 'Bfrtip',
buttons: [ ... ]
});
$('.menu .item').tab();
});
</script>

The best practice in Datatables is instead of bringing your data with foreach you should try datatables builtin ajax. I've faced same problem and solved by turning my data form to json with and made an ajax call.
PHP JSON Encode;
$object = (object) $arr;
echo json_encode($object);
Datatables Ajax Form;
var table = $('#example').DataTable({
fixedHeader: true,
"initComplete": function(){
$('.ui.loader').remove();
)
},
ajax: {
url: 'api/yourhandler.php',
type: 'GET',
data: {
searchTerm:searchTerm,
'pane':paneno,
project: projectFilter
},
},
order: [[ 0, "desc" ], [ 5, "asc" ]],
columnDefs: [
{ "searchable": true, "targets": [0,1,2,3,4,5] },
{ "className": "align-center", "targets": [0,2,3,4,5,6,7,8,9] },
{ "width": "1%", "targets": [2,3,4,5,6,7] },
{ "width": "10%", "targets": [8] },
{ "width": "25%", "targets": [1,9] }
],
columns: [
{ data: "columndata1" },
{ data: "columndata2" },
{ data: "columndata3" },
{ data: "columndata4" }
],
responsive: true,
paging: true,
pageLength: 25
});
If you choose not to make an ajax, I could say your problem cause is your data is not fit with the table. Try to focus your foreach, you will see the problem.

Related

How to populate ng-style with object of CSS

I have built an object of CSS that I've defined the CSS property name and value. The goal is to build out a form to manipulate the value and automatically update the CSS on the page visually for the user.
I have it all working except for an elegant way to actually style the item in real time.
Here is the link to example https://codepen.io/uncommonjoe/pen/KKXyzBp
This is the object I created that I'm working with
vm.card = [
{
class: "card",
properties: [
{
name: "background-color",
value: "#FFFFFF"
},
{
name: "border",
value: "1px solid #FFFFFF"
},
{
name: "border-radius",
value: "5px"
},
{
name: "box-shadow",
value: "0 0 26px rgb(0 0 0 / 20%)"
},
{
name: "margin",
value: "0"
},
{
name: "padding",
value: "0"
}
]
}
];
And in the HTML I'm using ng-repeat to build out form controls
<div ng-repeat="card in vm.card">
<b>{{card.class}}</b>
<div ng-repeat="object in card.properties">
<label>{{object.name}}</label>
<input type="text" ng-model="object.value" />
</div>
</div>
This is the example of the item. As you can see, that's not dynamic and reusable.
<div class="card" style="width: 18rem;"
ng-style="{
'background-color': vm.card[0].properties[0].value,
'border': vm.card[0].properties[1].value,
'border-radius': vm.card[0].properties[2].value,
'box-shadow': vm.card[0].properties[3].value,
'margin': vm.card[0].properties[4].value,
'padding': vm.card[0].properties[5].value,
}">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
I need a good way to do an ng-repeat so to speak in the ng-style and pull the name and define that as the CSS property and value as the value.
Define a styler function in your controller and then call it from ng-style:
vm.styler=function(props){
var styles={};
props.forEach(css=>{
styles[css.name]=css.value
})
return styles;
}
and in ng-style: ng-style="vm.styler(vm.cardObj[0].properties)"

v-spacer in datatable grouping header

I have a Vuetify project. I'm using the template with a slot group.header, so far so good.
Now I want to use a <v-spacer> in this template. Its in a <v-sheet>.
When I use the <v-spacer></v-spacer> I expect the content on the same line. But it will be on the next line. How can I display the button after the spacing on the same line, user Vuetify's system?
codepen
https://codepen.io/h3ll/pen/VwWOxdJ?editors=1010
HTML
<v-data-table
:headers="headers"
:items="desserts"
item-key="name"
sort-by="name"
group-by="category"
class="elevation-1"
show-group-by
>
<template v-slot:group.header="{items, isOpen, toggle}">
<th #click="toggle" colspan="12" class="ma-0 pa-0">
<v-sheet>
<v-icon class="mr-3">{{ isOpen ? 'mdi-folder-open' : 'mdi-folder' }}</v-icon>
{{ items[0].category }}
<v-spacer></v-spacer>
<v-btn x-small>I WANT TO BE ON THE RIGHT SIDE</v-btn>
</v-sheet>
</th>
</template>
</v-data-table>
javascript
new Vue({
el: '#app',
vuetify: new Vuetify(),
data () {
return {
headers: [
{
text: 'Dessert (100g serving)',
align: 'start',
value: 'name',
groupable: false,
},
{ text: 'Category', value: 'category', align: 'right' },
{ text: 'Dairy', value: 'dairy', align: 'right' },
],
desserts: [
{
name: 'Frozen Yogurt',
category: 'Ice cream',
dairy: 'Yes',
},
{
name: 'Ice cream sandwich',
category: 'Ice cream',
dairy: 'Yes',
},
...
],
}
},
})
Update
I can fix it with normal css like
<template v-slot:group.header="{items, isOpen, toggle}">
<th colspan="12">
<v-sheet>
<div #click="toggle" style="display: inline; width: 100vw">
<v-icon class="mr-3">{{ isOpen ? 'mdi-folder-open' : 'mdi-folder' }}</v-icon>
{{ items[0].folder }}
</div>
<div style="display: inline; float: right;">
<v-icon #click="deleteItem(item)">mdi-dots-vertical</v-icon>
</div>
</v-sheet>
</th>
</template>
```
But I wondering why Vuetify v-spacer is not working
v-spacer is basically just a div with the style flex-grow: 1. So to get this to work the parent container of the v-spacer needs to have display: flex.
In your case you can add this to v-sheet:
<v-sheet class="d-flex">
<!-- content -->
</v-sheet>

How to pass data from JsonResult to JQGrid in MVC?

I have used JQGrid to get the data from the controller which uses "GET". But, still I'm getting a blank table. I have also tried to apply breakpoints and check whether my variable "details" inside "Detail" Method getting value or not. It worked fine. I guess the problem is in returning the data in JSON format.
Controller
[HttpGet]
public JsonResult Detail()
{
IntegrationsProcessor db = new IntegrationsProcessor(new MCNIDbContext());
DBModel.Integrations row = db.GetIntegrationRow();
List<Integrations> details = new List<Integrations>
{
new Integrations
{
IntegrationName = row.IntegrationName,
CompanyEmail = row.CompanyEmail
}
};
return new JsonResult()
{
Data = details,
JsonRequestBehavior = JsonRequestBehavior.AllowGet,
MaxJsonLength = Int32.MaxValue
};
HTML file
#using MCNIDev.CustomControls
#model MCNIDev.Models.ViewModel.Integrations
#{
ViewBag.Title = "Details";
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=devicexb c-width" />
<title>Integrations</title>
</head>
#Styles.Render("~/Content/toasterCss")
#Styles.Render("~/Content/dataPickerCss")
<style type="text/css">
.btn {
min-width: 80px !important;
}
</style>
<body>
#using (Html.BeginForm("", "Integrations", FormMethod.Post, new { enctype = "multipart/form-data", #class = "form-horizontal", id = "frmManifestOrders" }))
{
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0 text-dark">Integrations</h1>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div><!-- /.content-header -->
<section class="content">
<div class="container-fluid">
<div class="card card-block">
<div class="row table-responsive">
<div class="col-md-12">
<div class="row">
<div class="col-md-12 col-sm-12">
<table id="tblSelectIntegrations"></table>
<div id="divSelect"></div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-12">
<hr />
<input type="button" class="btn btn-secondary" onclick="document.location.href='/Dashboard/Dashboard';" value="Cancel" />
</div>
</div>
</div>
</div>
</div>
</div>
</section>
}
</body>
</html>
#Scripts.Render("~/bundles/integrations")
<script>
$(document).ready(function(){
Integrate.GetValue();
});
</script>
JQGrid File
var Integrate = function() {
function GetValue() {
$("#tblSelectIntegrations").jqGrid({
type: "GET",
url: "/Integrations/Detail",
datatype: "json",
async: false,
colNames: [
"First Name", "Email Address"
],
colModel: [
//{
// name: '',
// key: false,
// width: 30,
// editable: true,
// formatter: function () {
// return "<input type='checkbox' value='Select' class='fm-button ui-state-default ui-corner-all fm-button-icon-left noPrint'\>";
// }
//},
{ key: false, name: 'IntegrationName', index: 'IntegrationName', editable: false, width: 200 },
{ key: false, name: 'CompanyEmail', index: 'CompanyEmail', editable: false, width: 200 },
// { key: false, name: 'Blank', index: 'Blank', editable: false, width: 200 }
],
pager: jQuery("#divSelect"),
rowNum: 1,
scroll: 0,
height: $(window).innerHeight() - 450,
width: "100%",
viewrecords: true,
caption: "Product",
emptyrecords: "No records to display",
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false
},
autowidth: true,
multiselect: false,
loadonce: false,
ajaxGridOptions: { cache: false },
gridComplete: function () {
},
}).navGrid("tblSelectIntegrations", { edit: false, add: false, del: false, search: false, refresh: false });
}
return {
GetValue: GetValue
};
}();
The issue lies in controller. I am trying to send data without telling JQGrid where to insert data.
var jsonData = new
{
rows = value
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
Replace below code with above code
return new JsonResult()
{
Data = details,
JsonRequestBehavior = JsonRequestBehavior.AllowGet,
MaxJsonLength = Int32.MaxValue
};
In my first code I've mentioned that add my data in the rows.

Best way to apply css class formatting on vuetify data table column

I have dynamically changing data for Vuetify's v-data-table:
<v-data-table
:headers="table_headers"
:items="table_content"
>
</v-data-table>
In the table_headers I can add "class" so that it can be used to apply custom css formatting on the headers:
table_headers: [
{
text: 'Dessert (100g serving)',
align: 'start',
sortable: false,
value: 'name',
class: 'section-dessert'
},
{ text: 'Calories', value: 'calories', class: 'section-calories' },
],
However this only affect headers. So my question is, would it be possible, or what is the best way to apply this class that I keep in table_headers also to all rows (per respective column).
So that when I write css for given class it will affect both header and all the rows for the given column.
EDIT:
So essentially I want to style whole column (on column basis), something like this:
Can I color table columns using CSS without coloring individual cells?
However with dynamic data for headers and table items (and since vuetify does not have working colgroup then Im not sure how to do something like this here)
You have to use the body slot to achieve that kind of customization, see below:
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
table_headers: [{
text: 'Dessert (100g serving)',
align: 'start',
sortable: false,
value: 'name',
class: 'section-dessert'
},
{
text: 'Calories',
value: 'calories',
class: 'section-calories'
},
],
table_content: [{
name: "Some dessert",
calories: 100
},
{
name: "Some dessert2",
calories: 200
},
{
name: "Some dessert3",
calories: 300
},
{
name: "Some dessert4",
calories: 400
}
]
}),
})
.section-dessert {
color: red !important;
}
.section-calories {
color: green !important;
}
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/#mdi/font#4.x/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify#2.x/dist/vuetify.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.0/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify#2.x/dist/vuetify.js"></script>
<body>
<div id="app">
<v-app>
<v-data-table :headers="table_headers" :items="table_content" hide-action hide-default-footer>
<template v-slot:body="{ items }">
<tbody>
<tr v-for="item in items" >
<td :class="table_headers[0].class">{{item.name}}</td>
<td :class="table_headers[1].class">{{item.calories}}</td>
</tr>
</tbody>
</template>
</v-data-table>
</v-app>
</div>
</body>

Jquery ui theme overwriting datatables css

I can't figure out why my jquery ui themeroller won't play nice with my datatables I'm trying to include in a dialog. The datatable uses the jquery-ui color and the columns are not readable. Am I missing something?
Here is my HTMl:
<div id="dvAdvanced" class="display" style="padding-top:40px;">
<table id="tblAdvSearch">
<thead>
<tr>
<th>Drawing #</th>
<th>Project</th>
<th>Customer</th>
<th>Created By</th>
<th>Date Created</th>
</tr>
</thead>
<tbody>
<tr>
<td>1#Html.DisplayFor(model => model.PartNumber)</td>
<td>2#Html.DisplayFor(model => model.RFQ)</td>
<td>3#Html.DisplayFor(model => model.customer_id)</td>
<td>#Html.DisplayFor(model => model.CreatedBy)</td>
<td>#Html.DisplayFor(model => model.DateCreated)</td>
</tr>
</tbody>
</table>
</div>
Here is my javascript:
$(document).ready(function () {
$("#btnAdvSearch").button();
$("#btnGenPart").button();
dlgAdvSearch = $("#dlgAdvSearch").dialog({
"jQueryUI": true,
title: "Advanced Search",
autoOpen: false,
height: 500,
width: 900,
modal: true,
buttons: {
Close: function () {
dlgAdvSearch.dialog("close");
}
}
});
$("#tabs").tabs();
$("#tblQuickSearch").dataTable();
$("#tblAdvSearch").dataTable();
$("#btnAdvSearch").button().on("click", function () {
dlgAdvSearch.dialog("open");
});;
});
And finally here is my bundleconfig:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css",
"~/Content/jquery-ui.min.css",
"~/Content/jquery-ui.structure.min.css",
"~/Content/jquery-ui.theme.min.css",
"~/Content//DataTables/css/jquery.dataTables.css",
"~/Content//DataTables/css/dataTables.jqueryui.css",
"~/Content/DataTables/css/jquery.dataTables_themeroller.css",
"~/Content/DataTables/css/dataTables.bootstrap.css"));

Resources