I tried to bind dynamically partial view its working but for jquery
datatable against first row what I specified below its not working.
#model IEnumerable<PurModelClass>
<table id="stock-audit-table" class="table table-striped table-bordered dt-responsive nowrap">
<thead>
<tr>
#*<th>Purchase From</th>
<th>Purchase Date</th>*#
<th>Item Name</th>
<th>Qty</th>
<th>Unit</th>
<th>Cost</th>
<th>Net Amount</th>
<th>Discount</th>
<th>Vat</th>
<th>Gross</th>
</tr>
</thead>
<tbody id="stock-audit-tbody">
#foreach (var item in Model)
{
<tr><td colspan="8">Invoice No: #item.PurInvNo Inv Date: #($"{#item.PurDate:MMM-dd-yyyy}") Vendor: #item.VendorName </td></tr>
foreach (var detail in item.PurDetails)
{
<tr>
<td>#detail.StockName</td>
<td>#detail.PurQty</td>
<td>#detail.UnitName</td>
<td>#detail.UnitPrice</td>
<td>#detail.Total</td>
<td>#detail.Discount</td>
<td>#detail.VAT</td>
<td>#detail.NetAmount</td>
</tr>
}
}
</tbody>
<tfoot>
</tfoot>
</table>
This the datatable script, is there any way to implement jquery datatable by demanding specific row with colspan properties.
<script type="text/javascript">
$(document)
.ready(function() {
$('#stock-audit-table').DataTable({
"autoWidth": false,
"order": [[0, "desc"]]
});
}
);
</script>
Try the rowGroup extension. You can use startRender and endRender to customize the summary data
$('#stock-audit-table').DataTable({
"autoWidth": false,
"order": [[0, "desc"]],
"rowGroup": {
dataSrc: 0,
startRender: function(groupName){
return $('<tr/>').append("<td colspan="8">TODO put data here</td>");
}
}
});
<tbody id="stock-audit-tbody">
#foreach (var item in Model)
{
foreach (var detail in item.PurDetails)
{
<tr>
<td>
<!-- Define a key to be referenced by the
'datasrc' property in dataTables -->
#item.GroupName
</td>
<td>#detail.StockName</td>
<td>#detail.PurQty</td>
<td>#detail.UnitName</td>
<td>#detail.UnitPrice</td>
<td>#detail.Total</td>
<td>#detail.Discount</td>
<td>#detail.VAT</td>
<td>#detail.NetAmount</td>
</tr>
}
}
</tbody>
Related
I'm trying to render lists of elements dynamically in ASPNETCore Razor Pages but I can't find the way to show the values of properties using Display Helper. M
<table class="table datatable">
<thead>
<tr>
#foreach (var item in Model.GetFieldNamesForList())
{
<th>
#Html.DisplayName(item)
</th>
}
<th></th>
</tr>
</thead>
<tbody>
#foreach (var item in Model.School) {
<tr>
#foreach (var propertyName in Model.GetFieldNamesForList())
{
<td>
// How to use #Html.Display using item from Model.School and the propertyName
</td>
}
<td>
<a asp-page="./Edit" asp-route-id="#item.Id" class="btn btn-primary btn-sm"><i class="material-icons md-16">edit</i></a>
<a asp-page="./Details" asp-route-id="#item.Id" class="btn btn-primary btn-sm"><i class="material-icons md-16">visibility</i></a>
<button action="submit" asp-page-handler="Delete" asp-route-id="#item.Id" class="btn btn-danger btn-sm"><i class="material-icons md-16">delete</i></button>
</td>
</tr>
}
</tbody>
</table>
In the meantime, I use reflection directly, but I would prefer use the Display method from helpers.
#item.GetType().GetProperty(propertyName).GetValue(item, null)
I had search reference and the reference say to try like this :
<?php
...
class ReportExport implements ShouldAutoSize, FromView, WithColumnFormatting, WithEvents
{
...
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
...
$event->sheet->getDelegate()->getRowDimension(37)->setRowHeight(-1);
$event->sheet->getDelegate()->getStyle('R37:Z37')->getAlignment()->setWrapText(true);
},
];
}
}
I try like that, but the result like this :
Should the height of row automatic added based content/text. But it does not added
How can I solve this problem?
Update :
Seems this script : $event->sheet->getDelegate()->getRowDimension(37)->setRowHeight(-1); is not working in the table
I tried the script outside the table, it worked. So the script only work outside table tag
My table like this :
<table>
....
#php ($group = 'A')
#php ($number = 0)
#foreach($values as $item)
#if($number==0 || $group!=$item['group'])
<tr>
<td colspan="9">Kelompok {{$item['group']}}</td>
<td colspan="2"></td>
<td colspan="3"></td>
<td colspan="3"></td>
<td colspan="9"></td>
<td colspan="2"></td>
<td colspan="3"></td>
<td colspan="3"></td>
<td colspan="9"></td>
</tr>
#php ($number = 0)
#endif
<tr>
<td style="text-align:center;" colspan="2">{{++$number}}</td>
<td colspan="7">{{$item['lesson_name']}}</td>
<td style="text-align:center;" colspan="2">{{$item['kb_pengetahuan']}}</td>
<td style="text-align:center;" colspan="3">{{$item['nilai_pengetahuan']}}</td>
<td style="text-align:center;" colspan="3">{{$item['predikat_pengetahuan']}}</td>
<td colspan="9">{{$item['deskripsi_pengetahuan']}}</td>
<td style="text-align:center;" colspan="2">{{$item['kb_keterampilan']}}</td>
<td style="text-align:center;" colspan="3">{{$item['nilai_keterampilan']}}</td>
<td style="text-align:center;" colspan="3">{{$item['predikat_keterampilan']}}</td>
<td colspan="9">{{$item['deskripsi_keterampilan']}}</td>
</tr>
#php ($group = $item['group'])
#endforeach
</table>
Please help me. I need support for PhpSpreadsheet functionality
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
...
$event->sheet->getDelegate()
->getStyle('R37:Z37')
->applyFromArray([ 'alignment' => ['wrapText' => true]])
},
];
}
I'm new to groovy xml parsing. I'm trying to parse the below xml file
<font face=Tahoma size=2>
Team,<br/><br/> Please find below the test summary details for the 'Test' execution.<br/><br/><b><U>Transaction Summary Table:</U></b><br/><br/>
<table border=1 CELLPADDING =3 style='font-family:Tahoma;font-size:12'>
<tr>
<b>
<th bgcolor=#C0C0C0> TransactionName </th>
<th bgcolor=#C0C0C0> AverageLatency </th>
<th bgcolor=#C0C0C0> MinimumLatency </th>
<th bgcolor=#C0C0C0> MaximumLatency </th>
<th bgcolor=#C0C0C0> AverageElapsedTime </th>
<th bgcolor=#C0C0C0> MinimumElapsedTime </th>
<th bgcolor=#C0C0C0> MaximumElapsedTime </th>
<th bgcolor=#C0C0C0> TotalCount </th>
<th bgcolor=#C0C0C0> PassPercentage </th>
</b>
</tr>
<tr>
<td>1 /aumentum/</td>
<td>
<center>1648.0</center>
</td>
<td>
<center>1240</center>
</td>
<td>
<center>2900</center>
</td>
<td>
<center>1907.0</center>
</td>
<td>
<center>1495</center>
</td>
<td>
<center>3140</center>
</td>
<td>
<center>45</center>
</td>
<td>
<center>100.0</center>
</td>
</tr>
<tr>
<td>T01_Aumentum_Home</td>
<td>
<center>6.0</center>
</td>
<td>
<center>1</center>
</td>
<td>
<center>10</center>
</td>
<td>
<center>1956.0</center>
</td>
<td>
<center>1490</center>
</td>
<td>
<center>3806</center>
</td>
<td>
<center>213</center>
</td>
<td>
<center>0.0</center>
</td>
</tr>
</tbody>
</table>
<br/><br/>Thanks,<br/>Performance Team.
</font>
<br/><br/>
Expected Result:
[{
"transaction name":"1 /aumentum/",
"AverageLatency ":"1648.0",
"Minimum latency":"1240",
"MaximumLatency ":"2900",
"AverageElapsedTime":"1907.0",
"MinimumElapsedTime":"1495",
"MaximumElapsedTime":"3140",
"TotalCount":"45",
"PassPercentage":"100.0"
},
{
"transaction name": "1 /aumentum/",
"AverageLatency ":"1648.0",
"Minimum latency":"1240",
"MaximumLatency ":"2900",
"AverageElapsedTime":"1907.0",
"MinimumElapsedTime":"1495",
"MaximumElapsedTime":"3140",
"TotalCount":"45",
"PassPercentage":"100.0"
}]
i have got the first children using values using docParser.getElementsByTag("tr").first()
Here is the error I get:
Exception thrown
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at org.jsoup.select.Elements.get(Elements.java:519)
at org.jsoup.nodes.Element.child(Element.java:174)
at org.jsoup.nodes.Element$child$0.call(Unknown Source)
at CommonUtils.parseLRHTMLReport(jmeteragent.groovy:304)
at CommonUtils$parseLRHTMLReport.call(Unknown Source)
Here is what I have done so far:
def transactiondetails12 = null
def iterator12 = 0
int count1 = 0
def violcounts = 0
def violations = null;
tmpElement = docParser.getElementsByTag("tr").first()
println tmpElement.children()
// tmpElement= tmpElement.child(0)
// println "#########tmpElement#########:" +tmpElement
for (element in tmpElement.children()) {
if (iterator12 == 0) {
// transactiondetails1 = "<table border=1 CELLPADDING =3 style='font-family:Tahoma;font-size:12'><tr><b><th bgcolor=#C0C0C0>" +
element.child(0).text().trim() + "</th><th bgcolor=#C0C0C0>" + element.child(2).text().trim() + "</th><th bgcolor=#C0C0C0>" +
element.child(3).text().trim() + "</th><th bgcolor=#C0C0C0>" + element.child(4).text().trim() + "</th></b></tr>"
iterator12 = 1;
count1++;
// println "nqwlieufrh 2938ry `9p23dhWCDNJ p3fu89 Q2390RUD"+transactiondetails1
} else {
count1++;
if (count1 <= 5) {
// println "iterator1iterator1iterator1iterator1"+iterator1++
transactiondetails12 = transactiondetails12 + "<tr><td>" + element.child(0).text().trim() + "</td><td><center>" +
element.child(2).text().trim() + "</center></td><td><center>" +
element.child(3).text().trim() + "</center></td><td><center>" +
element.child(4).text().trim()
println "transactiondetails12" + transactiondetails12
// println "3215463654156436212315465123011482145634217225445622341"+element.child(4).text().trim()
String violation1 = element.child(1).text()
// violation=Integer.valueOf(violation1)
// violation=Integer.parseInt(violation1)
// if(violation1>=0)
if (violation1.length() > 0) {
violcounts++
}
}
}
}
I have no idea how to map the tmpElement.children() values. Any advise on this would be helpful. Thanks in advance.
The sample you have provided uses jsoup library that is useful for HTML DOM manipulation. The solution to your problem is to use correct selectors to extract the data.
Consider following example:
def headers = docParser.select("tr > th").collect { it.text() }
def result = []
docParser.select("tr:has(td)").each { tr ->
def obj = [:]
tr.select("td").eachWithIndex { Element td, int i ->
obj[headers[i]] = td.text()
}
result << obj
}
println JsonOutput.prettyPrint(JsonOutput.toJson(result))
docParser.select("tr > th").collect { it.text() } collects table headers and stores them as an ordered List<String>
docParser.select("tr:has(td)") selects all rows (excluding table header) with data
tr.select("td").eachWithIndex iterates inside each row, collects the data and associates it with header by index i
the last line displays desired output to console
Output:
[
{
"TransactionName": "1 /aumentum/",
"AverageLatency": "1648.0",
"MinimumLatency": "1240",
"MaximumLatency": "2900",
"AverageElapsedTime": "1907.0",
"MinimumElapsedTime": "1495",
"MaximumElapsedTime": "3140",
"TotalCount": "45",
"PassPercentage": "100.0"
},
{
"TransactionName": "T01_Aumentum_Home",
"AverageLatency": "6.0",
"MinimumLatency": "1",
"MaximumLatency": "10",
"AverageElapsedTime": "1956.0",
"MinimumElapsedTime": "1490",
"MaximumElapsedTime": "3806",
"TotalCount": "213",
"PassPercentage": "0.0"
}
]
And here you can find full Groovy script I've used for experimenting with your example: https://gist.github.com/wololock/651a536dff4e104ebba0eef69d4ac3ea
I hope it helps.
So I'm creating website for a sports team. I have a "Results" page, where their scores for every round will be posted in form of table. Above the table I need to have two options, one that says "Season 2014/2015" and the other "Season 2015/2016", and I want two different tables displayed for each one of them? How do I do that?
You can do this by simply using jquery.Here is an example.
HTML
<div id="foo">
<span id="table1-btn">Table 1</span>
<span id="table2-btn">Table 2</span>
</div>
<table id="table1">
<tr>
<td>Table 1</td><td>Table 1</td>
</tr>
<tr>
<td>Table 1</td><td>Table 1</td>
</tr>
</table>
<table id="table2">
<tr>
<td>Table 2</td><td>Table 2</td>
</tr>
<tr>
<td>Table 2</td><td>Table 2</td>
</tr>
</table>
css
#foo{
width:200px;
height:auto;
padding:5px;
}
#table1-btn,
#table2-btn{
width:100px;
height:auto;
padding:5px;
background-color:#e3e3e3;
cursor:pointer;
}
jQuery
$(document).ready(function () {
$('#table2').hide();
$('#table1-btn').click(function () {
$('#table2').hide();
$('#table1').show();
});
$('#table2-btn').click(function () {
$('#table1').hide();
$('#table2').show();
});
});
Find jsfiddle code Here
If you are using bootstrap, you could look into tabs: http://getbootstrap.com/javascript/#tabs
Have your tables in a tab 2014/2015 and the other tables in a tab 2015/2016
In my MVC3 Web application I have a aspx main view page and a partial View Page. My table is in Partial view. I have also applied Table sorter and other table css to it. Now I want to export data from this table to excel. I tried so many ways but it didn't worked for me. Can anyone Help Me Please...
Code of my partial view is:
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<ApricaCRMEvent.Models.CRM.DatabaseEntities.CRM_Doctor_Request>>" %>
<!-- for table sorter and table Pager -->
<script src="../../__jquery.tablesorter/jquery.tablesorter.js" type="text/javascript"></script>
<script src="../../__jquery.tablesorter/jquery.tablesorter.widgets.js" type="text/javascript"></script>
<script src="../../__jquery.tablesorter/jquery.tablesorter.pager.js" type="text/javascript"></script>
<script type ="text/javascript" id="js">
$(function () {
// **********************************
// Description of ALL pager options
// **********************************
var pagerOptions = {
// target the pager markup - see the HTML block below
container: $(".pager"),
// use this url format "http:/mydatabase.com?page={page}&size={size}&{sortList:col}"
ajaxUrl: null,
// process ajax so that the data object is returned along with the total number of rows
// example: { "data" : [{ "ID": 1, "Name": "Foo", "Last": "Bar" }], "total_rows" : 100 }
ajaxProcessing: function (ajax) {
if (ajax && ajax.hasOwnProperty('data')) {
// return [ "data", "total_rows" ];
return [ajax.data, ajax.total_rows];
}
},
// output string - default is '{page}/{totalPages}'
// possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
output: '{startRow} to {endRow} ({totalRows})',
// apply disabled classname to the pager arrows when the rows at either extreme is visible - default is true
updateArrows: true,
// starting page of the pager (zero based index)
page: 0,
// Number of visible rows - default is 10
size: 10,
// if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty
// table row set to a height to compensate; default is false
fixedHeight: true,
// remove rows from the table to speed up the sort of large tables.
// setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
removeRows: false,
// css class names of pager arrows
cssNext: '.next', // next page arrow
cssPrev: '.prev', // previous page arrow
cssFirst: '.first', // go to first page arrow
cssLast: '.last', // go to last page arrow
cssGoto: '.gotoPage', // select dropdown to allow choosing a page
cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed
cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option
// class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page)
cssDisabled: 'disabled' // Note there is no period "." in front of this class name
};
// Extend the themes to change any of the default class names ** NEW **
$.extend($.tablesorter.themes.jui, {
// change default jQuery uitheme icons - find the full list of icons here: http://jqueryui.com/themeroller/ (hover over them for their name)
table: 'ui-widget ui-widget-content ui-corner-all', // table classes
header: 'ui-widget-header ui-corner-all ui-state-default', // header classes
footerRow: '',
footerCells: '',
icons: 'ui-icon', // icon class added to the <i> in the header
sortNone: 'ui-icon-carat-2-n-s',
sortAsc: 'ui-icon-carat-1-n',
sortDesc: 'ui-icon-carat-1-s',
active: 'ui-state-active', // applied when column is sorted
hover: 'ui-state-hover', // hover class
filterRow: '',
even: 'ui-widget-content', // odd row zebra striping
odd: 'ui-widget-content' // even row zebra striping
});
// call the tablesorter plugin and apply the ui theme widget
$("table").tablesorter({
theme: 'jui', // theme "jui" and "bootstrap" override the uitheme widget option in v2.7+
headerTemplate: '{content} {icon}', // needed to add icon for jui theme
// widget code now contained in the jquery.tablesorter.widgets.js file
widgets: ['uitheme', 'zebra'],
widgetOptions: {
// zebra striping class names - the uitheme widget adds the class names defined in
// $.tablesorter.themes to the zebra widget class names
zebra: ["even", "odd"]
// set the uitheme widget to use the jQuery UI theme class names
// ** this is now optional, and will be overridden if the theme name exists in $.tablesorter.themes **
// uitheme : 'jui'
}
})
// bind to pager events
// *********************
.bind('pagerChange pagerComplete pagerInitialized pageMoved', function (e, c) {
var msg = '"</span> event triggered, ' + (e.type === 'pagerChange' ? 'going to' : 'now on') +
' page <span class="typ">' + (c.page + 1) + '/' + c.totalPages + '</span>';
$('#display')
.append('<li><span class="str">"' + e.type + msg + '</li>')
.find('li:first').remove();
})
// initialize the pager plugin
// ****************************
.tablesorterPager(pagerOptions);
});
</script>
<!-- end table sorter and table Pager -->
<table class="tablesorter" id="ResultList">
<thead id="headers">
<tr>
<th>
CRMId
</th>
<th>
Territory
</th>
<th>
Doctor(MDLNo)
</th>
<th>
Requester
</th>
<th>
Suggester
</th>
<th>
Division
</th>
<th>
Estimated
</th>
<th>
Actual
</th>
<th>
Priority
</th>
<th>
Notation
</th>
<th>
Deadline
</th>
<th>
ExecutedDate
</th>
<th>
CreatedDate
</th>
<th>
CRM State
</th>
<th>
Service State
</th>
</tr>
</thead>
<tbody>
<% foreach (var item in Model) { %>
<tr>
<td>
<%: Html.ActionLink(((int)item.Id).ToString(), "DetailsCRMRequest", "CRM", new { Id = item.Id, controllerName = "FilterCRMRequest", actionName = "Index" }, null)%>
<%--<%: Html.DisplayFor(modelItem => item.Id) %>--%>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Territory_Name) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Request_For_Name) %> (<%: Html.DisplayFor(modelItem => item.Request_For_Id) %>)
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Requester_Name) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Suggester_Name) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Division_Name) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Estimated_Amount) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Actual_Amount) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Compute_Priority) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.CRM_Notation_Name) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Deadline) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Executed_Date) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Date_Created) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Compute_CRM_State) %>
</td>
<td>
<%: Html.DisplayFor(modelItem => item.Compute_Service_State) %>
</td>
</tr>
<% } %>
</tbody>
<tfoot>
<tr class="pager" align="center">
<td colspan="15">
<img src="../../Content/images/first.png" class="first" alt="First" />
<img src="../../Content/images/prev.png" class="prev" alt="Prev" />
<span class="pagedisplay"></span> <!-- this can be any element, including an input -->
<img src="../../Content/images/next.png" class="next" alt="Next" />
<img src="../../Content/images/last.png" class="last" alt="Last" />
<select class="pagesize" title="Select page size">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
</select>
<select class="gotoPage" title="Select page number"></select>
</td>
</tr>
</tfoot>
</table>
I have already tried this : this works but gives me css in Excel file and 5 td fields from all 50 records result...
function Export(e) {
window.open('data:application/vnd.ms-excel,' + $('#ResultList').html());
e.preventDefault();
}
and this : it doesn't worked totally...
function Export() {
alert("called function");
str = "";
var myTableHead = document.getElementById('headers');
var rowCount = myTableHead.rows.length;
var colCount = myTableHead.getElementsByTagName("tr")[0].getElementsByTagName("th").length;
var ExcelApp = new ActiveXObject("Excel.Application");
var ExcelSheet = new ActiveXObject("Excel.Sheet");
ExcelSheet.Application.Visible = true;
alert("before for");
for (var i = 0; i < rowCount; i++) {
for (var j = 0; j < colCount; j++) {
str = myTableHead.getElementsByTagName("tr")[i].getElementsByTagName("th")[j].innerHTML;
ExcelSheet.ActiveSheet.Cells(i + 1, j + 1).Value = str;
}
}
alert("done");
}