I am using php/mysql and use adminator theme to show result table in datatables
https://colorlib.com/polygon/adminator/datatable.html
i used order by desc in sql query and when i print results it show correct results in desc form. but when i show them in datatable they are shown by asc. i tried changing below file by adding aaSorting : [[0, 'desc']]
/assets/scripts/datatable/index.js
import * as $ from 'jquery';
import 'datatables';
export default (function () {
$('#dataTable').DataTable({aaSorting : [[0, 'desc']]});
}())
but its not working.
Related
I have two tables in the analysis. I am using the script below to be able to filter table A and pass those filter selections to the matching filter in table B. Table A and B are visualized in a bar chart. I am triggering the code when the value of a document property changes, following instructions here.
I am running into two problems.
1) After the script runs, clicking Reset All Filters results in only table A being displayed in the visualization. Clicking Reset All Filters again fixes the issue.
2)When I add a second filter (commented out in the code below), making a selection in the Type_A or or Type_B filter wipes out the type B data from the visualization. I think the problem is in how IncludeAllValues is being handled, but I don't know how to fix it. Any help will be appreciated.
from Spotfire.Dxp.Application.Filters import *
from Spotfire.Dxp.Application.Visuals import VisualContent
from System import Guid
#Get the active page and filterPanel
page = Application.Document.ActivePageReference
filterPanel = page.FilterPanel
theFilterA = filterPanel.TableGroups[0].GetFilter("Type_A")
lbFilterA = theFilterA.FilterReference.As[ListBoxFilter]()
theFilter2A = filterPanel.TableGroups[1].GetFilter("Type_A")
lb2FilterA = theFilter2A.FilterReference.As[ListBoxFilter]()
lb2FilterA.IncludeAllValues = False
lb2FilterA.SetSelection(lbFilterA.SelectedValues)
#########################Type_B###########################
# theFilterB = filterPanel.TableGroups[0].GetFilter("Type_B")
# lbFilterB = theFilterB.FilterReference.As[ListBoxFilter]()
# theFilter2B = filterPanel.TableGroups[1].GetFilter("Type_B")
# lb2FilterB = theFilter2B.FilterReference.As[ListBoxFilter]()
# lb2FilterB.IncludeAllValues = False
# lb2FilterB.SetSelection(lbFilterB.SelectedValues)
I want to display a data (in my case, a String) by using Query component on Pentaho CDE. However, nothing is displayed.
Here is what I did:
On DataSource Panel:
The query is
select city_name from tb_city where city_id='1';
and it gives 'NYC' as result.
Then On Component Panel - Query Component:
With a JS function on Post Execution:
function f() {
document.getElementById('header_c').innerHTML =myresult;
}
where header_c is the name of the column where I want to display the query result.
I think there's no prob with this function and other stuffs because when I change myresult to any string like 'HELLO' in the function, it's displayed.
Does anyone have an idea where's wrong? I verified and the query has no prob.
write this code in your post fetch. where abc is Result Var
function fun(abc) {
document.getElementById('qq1').innerHTML =abc.resultset;
}
Here i have fetched the data from controller , all are coming fine (according to the alphabetical order) ,but in data table its not coming what i want to get ,means in alphabetical order while viewing .
Here all the data in descending order by default
aaSorting: [[0, "desc"]],
I need it to be sort according to the name field in alphabetical order
I have attached a snap for more clarification.
Here i want all the center name should be in alphabetical order.
Please suggest me.
<script>
$(document).ready(function () {
$('#example1').DataTable({
aaSorting: [[0, "asc"]]
});
});
</script>
After doing a research ,finally got to know this .
i just added this js codes below of this page .
And results came ,what i need.
It may be helpful to anyone else .
Thank you .
I've made a script that takes data from a spreadsheet , creates a Google Doc and presents selected rows in a Table format in the Doc. Now I'd like to be able to sort that table Alphabetically before the table is created. I've tried using a couple of different approaches like this
function onEdit(){
var sh = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var editedCell = sh.getActiveRange().getColumnIndex();
if(editedCell == 2) {
var range = sh.getRange("A2:B10");
range.sort({column: 2});
}
}
This kind of sort works but only onEdit(). I'd like to sort before edit or find away to sort the table as the Google Doc is being generated.
Does anyone have any suggestions.
Many thanks in advance.
Use the onOpen() function instead of the onEdit() function.
Note that you will have to open the document, not just refresh the page to get the function to run.
I have requirement in which i am getting product ID from external Application with product super_attribute options like color,size. I am getting all those and i can do the add to cart option.
But here my actual requirement is to select the requested options by customer and redirect them to product detail page in magento so that here they can still enter optional text to print. So i need to set the requested options in detail page and redirect them to product detail page instead of adding it to cart. They will enter more details and then they will do addtocart manually.
How can i set the selected options while loading itself.
Please help me.
Thankfully this is already built in to most themes. You need to know the ID of both attributes and values from the Simple product that is included in the Configurable product. I've only seen it work with Configurable types so that might be a limitation.
For each attribute make a key=value pair
Combine the attributes as a query string, eg. "123=345&678=890"
Append the string as a hash fragment (not as a query).
This is an example from the official demo, note that the first option needs to be selected for the second to work so it has two key/value pairs.
http://demo.magentocommerce.com/zolof-the-rock-and-roll-destroyer-lol-cat-t-shirt-126.html#525=99&272=22
Rough Magento2 example add the below for pre-selecting the custom options by name=value in:
/www/mysite/app/design/frontend/mycompany/mytheme/Magento_Catalog/templates/product/view/options.phtml
The below code looks at the label of the option and the text value of the select. And depends on your theme structure. Example below for Luma.
It expects the following format in the url
product.html?SelectLabel=OptionValue&SelectLabel=OptionValue
This does not account for multi language etc.. you could easily adapt it to instead look for the select id and option id which would be more accurate replacing
$(label).parents().eq(1).find('select option:contains('+arr[k]+')').attr('selected', true);
with (untested)
$("#"+k+" option[id='"+arr[k]+"']").attr("selected", "selected");
<script>
require(['jquery'],function($){
$(document).ready(function(){
function getJsonFromUrl() {
var query = location.search.substr(1);
var result = {};
query.split("&").forEach(function(part) {
var item = part.split("=");
result[item[0]] = decodeURIComponent(item[1]);
});
return result;
}
var arr = getJsonFromUrl();
for (var k in arr){
if (arr.hasOwnProperty(k)) {
//alert("Key is " + k + ", value is" + arr[k]);
var label = $('.product-options-wrapper').find("span:contains('"+k+"')");
$(label).parents().eq(1).find('select option:contains('+arr[k]+')').attr('selected', true);
}
}
});
});
</script>