I have one div and under that i have kendo grid. I want to give 100% height or auto height to div but when i give that Kendo Grid header is getting long and close that div as in image
But i want to show view like this
I don't want to give fix value to first div element because item detail is different for all detail so it need to be auto.
Here my css & html
<style>
#gauge-container {
text-align: right;
margin: 0px auto;
background: transparent url(#Url.Content("~/Content/linear-gauge-container.png")) no-repeat 50% 50%;
padding: 18px;
width: 100px;
height: 300px;
float:left;
}
.k-gauge {
height: 300px;
display: inline-block;
zoom:1;
}
##media(max-width:768px) {
.div1 {
overflow:auto;
}
}
##media(min-width:768px) {
.div1 {
height:100%;
}
}
</style>
<div class="div1">
#for (int i = 0; i < tanklist.Count; i++)
{
<table>
<tr>
<td><b>Capacity</b></td>
<td>:</td>
<td><b>#tanklist[i].TnkKapasite.ToString("N0", nf) LT</b></td>
</tr>
<tr>
<td>Fuel</td>
<td>:</td>
<td>#tanklist[i].StokKod</td>
</tr>
<tr>
<td>Time</td>
<td>:</td>
<td>#tanklist[i].Time</td>
</tr>
<tr>
<td><b>Fuel Vol.</b></td>
<td>:</td>
<td><b>#tanklist[i].FuelVolume.ToString("N0", nf) LT</b></td>
</tr>
<tr>
<td>Ullage</td>
<td>:</td>
<td>#tanklist[i].Ullage.ToString("N0", nf) LT</td>
</tr>
<tr>
<td>Water Vol.</td>
<td>:</td>
<td>#tanklist[i].WaterVolume.ToString("N0", nf) LT</td>
</tr>
<tr>
<td>Temperature</td>
<td>:</td>
<td>#tanklist[i].Temperature</td>
</tr>
</table>
}
</div>
<div style="height:100%;">
#( Html.Kendo().Grid<Deliveries>()
.Name("grdTank_" + (string)data)
.DataSource(ds => ds
.Ajax()
.Read(r => r.Action("GridBinding", "Dashboards", new { code = data, tip = tip }))
)
.Columns(columns =>
{
columns.Bound(e => e.Tank).Width(80).Title("Tank");
columns.Bound(e => e.StartTime).Width(100).Title("Start Time").ClientTemplate("#= kendo.toString(StartTime, 'dd.MM.yyyy HH:mm:ss') #");
columns.Bound(e => e.EndTime).Width(100).Title("End Time").ClientTemplate("#= kendo.toString(EndTime, 'dd.MM.yyyy HH:mm:ss') #");
columns.Bound(e => e.Fuel).Width(50).Title("Fuel");
columns.Bound(e => e.DeliveredVolume).Width(100).Title("Delivered Volume").ClientTemplate("<div style='text-align:right;'>#= FormatNumber(DeliveredVolume) # LT</div>").Encoded(true);
columns.Bound(e => e.ProductVolumeAfter).Width(100).Title("Product Volume After").ClientTemplate("<div style='text-align:right;'>#= FormatNumber(ProductVolumeAfter) # LT</div>").Encoded(true);
})
.Selectable()
.Scrollable(scrolling => scrolling.Height("auto"))
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(10))
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.StartsWith("Starts with")
.Contains("Contains")
))
)
//.Groupable()
.Resizable(config =>
{
config.Columns(true);
})
.Reorderable(config =>
{
config.Columns(true);
})
.ColumnMenu()
)
</div>
Thanks
First of all this answer helped me here
I gave class name to my grid and i float:left this two div then used clear div after that problem solved.
.div1 {
float:left;
}
.clear {
clear:both;
}
.grdTank
{
width: 100%;
float:left;
}
Related
im creating custom dynamic table(table creates according to the given data) and need to show only 6 columns and others should see when scrolling.
What need to do is only show first 6 weeks and others should see when scrolling (here 7 to 10 weeks) and Win and Lose column should be static(freeze) and scrolling should be only applicable to week columns except Win and Lose.
What i Tried:
I have added some CSS part to make table scorable for vertically and horizontally but couldn't able add <div> tags to get the desired output.
Code is given below:
import "./styles.css";
export default function DataTable7() {
let totalWeeks= 10;
const rawData = [
[15,'','','',1,'',1,'','',5,8,7],
[7,'','','',1,'',1,'','',5,2],
[6,'','','','','','','',6,0],
[3,'','','','','','',2,0],
[2,1,'','','','',1,1],
[2,'','','','',2,0],
[1,'','','',1,0],
[2,'',1,1,1],
[2,'',1,0],
['-','-','-']
];
const NetLostInitial= rawData.map(x => x[x.length-2]);
const NetReturnedInitial= rawData.map(x => x[x.length-1]);
const NetLost = NetLostInitial.filter(
element => typeof element === 'number'
);
const NetReturned = NetReturnedInitial.filter(
element => typeof element === 'number'
);
const TotalNetLost=NetLost.reduce((partialSum, a) => partialSum + a, 0);
const TotalNetReturned=NetReturned.reduce((partialSum, a) => partialSum + a, 0);
return (
<>
<div className="tableContainer">
<table className="lostAssets">
<thead>
<tr>
<th>Week</th>
{new Array(totalWeeks).fill(null).map((_, i) => {
return <th>{i+1}</th>;
})}
<th>Win</th>
<th>Lose</th>
</tr>
</thead>
{/* [7,'','','',1,'',1,'','',5,2], */}
<tbody>
{rawData.map((item, index) => {
return (
<>
<tr>
<th>{index + 1}</th>
{[...Array(rawData[0].length - item.length)].map((item) => {
return <td></td>; //for empty values
})}
{item.map((itm) => {
return <td>{itm}</td>;
})}
</tr>
</>
);
})}
<tr>
<th></th>
{new Array(totalWeeks).fill(null).map((_, i) => {
return <td></td>;
})}
<td>{TotalNetLost}</td>
<td>{TotalNetReturned}</td>
</tr>
</tbody>
</table>
</div>
</>
);
}
CSS part:
table, tr, td, th {
border: 1px solid #9b9b9b;
border-collapse: collapse;
text-align: center;
padding: .4em;
}
.tableContainer{
height: 200px;
width: 344px;
overflow: scroll;
}
Table thead{
position: sticky;
top: 0px;
margin: 0 0 0 0;
}
I have a MVC application where I am populating a grid from my model. A model property "RAG" has a string containing color name. Based on which I am populating the grid with a small colored square.
#foreach (var item in Model)
{
<tr>
<td>
#Html.DisplayFor(modelItem => item.DMRTitle)
</td>
<td>
#Html.DisplayFor(modelItem => item.PlannedDate)
</td>
<td>
#if (item.RAG == "Green")
{
<div style="height: 20px; width: 20px; background-color: lightgreen"></div>
}
else if (item.RAG == "Amber")
{
<div style="height: 20px; width: 20px; background-color: orange"></div>
}
else
{
<div style="height: 20px; width: 20px; background-color: orangered"></div>
}
</td>
</tr>
}
This code works fine and my Grid is rendered as expected.
Now I wanted to add SOrting and Filtering feature, so I changed my Grid to Grid.MVC.
I am able to render the columns as text using this code.
<div>
#Html.Grid(Model).Columns(columns =>
{
columns.Add(c => c.DMRTitle).Titled("Milestone").Filterable(true).SetWidth(100);
columns.Add(c => c.PlannedDate).Titled("Planned Date").Format("{0:dd-MMM-yyyy}").Filterable(true).SetWidth(100);
columns.Add(c => c.RAG).Titled("RAG").Filterable(true).SetWidth(100);
}).WithPaging(5).Sortable(true)
How Can I change the Text in the RAG column to the colored squares that I was using before?
If adding a square is not possible, then can I change the cell background color based on the value it contains? that will also work for me.
Finally I found a solution to this.
I just added the columns as this
columns.Add(c => c.RAG).Titled("RAG").Filterable(true).Sanitized(false).Encoded(false).RenderValueAs(c => new HtmlString(
"<div style='height: 20px; width: 20px; background-color: " + GetColorForRag(c.RAG) + "'></div>"
)).SetWidth(50);
and this is the color function
#functions
{
public string GetColorForRag(string RAG)
{
if (RAG == "Red")
return "Orangered";
else if (RAG == "Amber")
return "orange";
else
return "lightgreen";
}
}
I have some table and I want to make it responsive when it show in width max 760.
This is the table looks normal :
And I want to make it like this if width of the screen is max 760 :
In that table the last coloumn just appears in end of table not in each row.
Anyone can help me to do that ?
Use this html & css code for make rsponsive table
Check the Snippets is below .
Use this css with media query max-width:760px or any width
.responsive-table {
margin:0px auto;
width:500px;
border: 1px solid #efebeb;
}
.responsive-table img{height:100px; }
.responsive-table th {
display: none;
}
.responsive-table td {
display: block;
border-top: 1px solid #ddd;
}
.responsive-table td:first-child{border:none;}
.responsive-table td:first-child {
padding-top: .5em;
}
.responsive-table td:last-child {
padding-bottom: .5em;
}
.responsive-table td:before {
content: attr(data-th) ": ";
display:block;
font-weight:bold;
}
<table class="responsive-table">
<tbody>
<tr>
<th>
Room
</th>
<th>
Guest
</th>
<th>
Description
</th>
<th>
Rate
</th>
<th>
Book
</th>
</tr>
<tr>
<td data-th="Room">
<img src="http://i45.tinypic.com/t9ffkm.jpg" alt="" />
</td>
<td data-th="Guest">
2 adult
</td>
<td data-th="Description">
Room Only
</td>
<td data-th="Rate">
USD 200
</td>
<td data-th="Book">
<button type="submit"> Book</button>
</td>
</tr>
</tbody>
</table>
I wrote js function to make table responsive. You can set breakpoint and table tag or css class name as parameters.
const makeTableResponsive = (mq, t) => {
var q = window.matchMedia(mq);
if (q.matches) {
let headings = [];
let tables = document.querySelectorAll(t);
if (tables && tables.length > 0) {
tables.forEach(table => {
let thead = table.querySelector("thead");
let headingTags = thead.querySelectorAll("th");
let tbody = table.querySelector("tbody");
let tbodies = tbody.querySelectorAll("tr");
tbody.style.display = "block";
thead.style.display = "none";
headingTags.forEach((th) => {
th.style.display = "block";
headings.push(th.innerText);
});
tbodies.forEach((tr) => {
let trstyle = tr.style;
trstyle.display = "block";
trstyle.border = "1px solid #ccc";
trstyle.marginBottom = "30px";
let tds = tr.querySelectorAll("td");
tds.forEach((td, i) => {
td.style.display = "flex";
td.style.flexDirection = "row-reverse";
td.style.justifyContent = "space-between";
td.innerHTML += `<span class="font-weight-bold text-primary">${headings[i]}</span>`;
});
});
})
}
}
};
makeTableResponsive('(max-width: 992px)', 'table');
I am using CGridView with 'raw' cell type. The cell contains text field generated using CHtml::textField. Here I cannot change the width of the column using headerHtmlOptions or htmlOptions. Please help.
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'mbook-grid',
'itemsCssClass'=>'table table-bordered table-condensed table-hover table-striped dataTable',
'dataProvider'=>$model->search(),
'afterAjaxUpdate'=>'calcquantity',
'enablePagination' => true,
'pagerCssClass'=>'dataTables_paginate paging_bootstrap table-pagination',
'pager' => array('header'=>'','htmlOptions'=>array('class'=>'pagination')),
'columns' => array(
array(
'class' => 'CCheckBoxColumn',
'id'=>'project_estimate_id',
'htmlOptions'=>array('style' => 'display:none'),
'headerHtmlOptions'=>array('style' => 'display:none'),
'selectableRows'=>2,
'value'=>'$data["project_estimate_id"]',
'checked'=>'true',
),
array('name'=>'description','value'=>'CHtml::textField("ProjectMBookGrid[description_".$data["project_estimate_id"]."]",$data["description"],array("class"=>"gridfield"))','type'=>'raw','header'=>'Description','headerHtmlOptions'=>array('style'=>'width: 5%;')),
array('name'=>'length','value'=>'CHtml::textField("ProjectMBookGrid[length_".$data["project_estimate_id"]."]",$data["length"],array("class"=>"gridfield","style"=>"text-align: right"))','type'=>'raw','header'=>'Length','headerHtmlOptions'=>array('style'=>'width:5%')),
array('name'=>'breadth','value'=>'CHtml::textField("ProjectMBookGrid[breadth_".$data["project_estimate_id"]."]",$data["breadth"],array("class"=>"gridfield","style"=>"text-align: right"))','type'=>'raw','header'=>'Breadth','htmlOptions'=>array('style'=>'text-align: right')),
array('name'=>'quantity','value'=>'CHtml::textField("ProjectMBookGrid[quantity_".$data["project_estimate_id"]."]",$data["quantity"],array("class"=>"gridfield","style"=>"text-align: right"))','type'=>'raw','header'=>'Quantity','htmlOptions'=>array('style'=>'text-align: right')),
),
'htmlOptions'=>array('class'=>'grid-view table-responsive hide-x-scroll'),
))
Below is the CSS
.table.dataTable {
clear: both;
margin-bottom: 10px;
}
.table-bordered.dataTable {
border-top: 1px solid #ddd;
}
table {
background-color: transparent;
max-width: 100%;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
.hide-x-scroll {
overflow-x: scroll;
}
.grid-view {
padding: 15px 0;
}
I added
"style"=>"width:100%"
in CHtml::textField htmlOptions and was able to change the width of column
Can someone help a CSS newbie out? I have a main section that then has a section inside of it. I need to center the 2nd section inside the main section. How can you do this? Here is my code.
.section1 {
border: 1px solid #CCCCCC;
padding: 10px;
overflow: hidden;
margin-left: auto;
margin-right: auto;
}
.section2 {
padding:10px; overflow:hidden;
margin-left: auto;margin-right: auto;
}
<section class="section1">
<section class="section2">
<div>
Registration Status
#Html.TextBoxFor(model => model.RegSts, new { disabled = true, size="10" })
Admitting Program
#Html.TextBoxFor(model => model.AdmProg, new { disabled = true, size="10" })
Academic Location
#Html.TextBoxFor(model => model.Loc, new { disabled = true, size="10" })
Division
#Html.TextBoxFor(model => model.Div, new { disabled = true, size="10" })
</div>
</section>
</section>