tooltip: {
headerFormat: '',
pointFormatter: function() {
let txt = <tr style="border: 1px solid red;"><td>DATA1</td></tr>
txt += <tr style="border: 1px solid red;"><td>DATA1</td></tr>
return txt
},
footerFormat: '',
shared: true,
useHTML: true
}
Related
I am trying to pass parameters from the current record to an embedded Suitelet though cannot find the right syntax to do this anywhere
My starting point was using the Suitelet code here: https://timdietrich.me/blog/netsuite-suiteql-query-results-custom-tabs/
The result from my modified version is per this screencap
When the page loads, the SuiteQL record field is populated using the current record's internal Id.
What I want to do is pass this value as a variable to the embedded SuiteQL Suitelet so that the search results are only in relation to the stated record (in this case, the record with the internal id=24486).
Is this actually possible?
If it is possible, how do I pass this value to the SQL query parameters?
This is the full modified version of the code:
/**
* #NApiVersion 2.1
* #NScriptType UserEventScript
* #NModuleScope Public
*/
/*
*/
var log, query, serverWidget;
define([
"N/log",
"N/query",
"N/ui/serverWidget",
"N/record",
"N/runtime",
"N/recordContext",
], main);
function main(
logModule,
queryModule,
serverWidgetModule,
recordModule,
runtimeModule,
recordContextModule
) {
log = logModule;
query = queryModule;
serverWidget = serverWidgetModule;
record = recordModule;
runtime = runtimeModule;
recordContext = recordContextModule;
return {
beforeLoad: beforeLoad,
};
}
function beforeLoad(context) {
if (context.type !== context.UserEventType.VIEW) {
return;
}
var suiteqlTab = context.form.addTab({
id: "custpage_sql_tab",
label: "SuiteQL Tab",
});
context.form.insertTab({
tab: suiteqlTab,
nexttab: "items",
});
var recordId = runtime.getCurrentScript();
log.debug({
title: "recordId",
details: recordId,
});
var parms = context.request.parameters;
log.debug("params", parms);
log.debug("recordid", parms.id);
var id = parms.id;
var recordField = context.form.addField({
id: "custpage_suiteql_record",
type: serverWidget.FieldType.TEXT,
label: "SuiteQL Record",
container: "custpage_sql_tab",
});
recordField.defaultValue = id;
var suiteqlField = context.form.addField({
id: "custpage_suiteql_field",
type: serverWidget.FieldType.TEXT,
label: "SuiteQL Query Results",
container: "custpage_sql_tab",
});
var records = sqlQueryRun();
context.newRecord.setValue({
fieldId: "custpage_suiteql_field",
value: sqlResultsTableGenerate(records),
});
}
function sqlQueryRun() {
var sql = `
SELECT
Transaction.type
FROM
Transaction
Where Transaction.type like 'SalesOrd'
`;
return query.runSuiteQL({ query: sql, params: [] }).asMappedResults();
}
function sqlResultsTableGenerate(records) {
if (records.length === 0) {
return "<div><p>No records were found.</p></div>";
}
let thead = `
<thead>
<tr>
<th>Last Name</th>
<th>First Name</th>
<th>Email</th>
<th>Phone #</th>
</tr>
</thead>`;
var tbody = "<tbody>";
for (r = 0; r < records.length; r++) {
var record = records[r];
tbody += `
<tr>
<td></td>
<td></td>
<td>${record.email}</td>
<td>${record.phone || ""}</td>
</tr>`;
}
tbody += "</tbody>";
let stylesheet = `
<style type = "text/css">
/* Styled Table */
/* https://dev.to/dcodeyt/creating-beautiful-html-tables-with-css-428l */
.styled-table {
border-collapse: collapse;
margin: 25px 0;
font-size: 0.9em;
font-family: sans-serif;
min-width: 400px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
width: 100%;
}
.styled-table th,
.styled-table td {
padding: 6px;
}
.styled-table thead tr {
background-color: #607799;
color: #ffffff;
text-align: left;
}
.styled-table tbody tr {
border-bottom: thin solid #dddddd;
}
.styled-table tbody tr:nth-of-type(even) {
background-color: #f3f3f3;
}
.styled-table tbody tr.active-row {
font-weight: bold;
color: #009879;
}
.styled-table tbody tr:hover {
background-color: #ffff99;
}
</style>
`;
return `
${stylesheet}
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script>
<div style="margin-top: 6px; border: 1px solid #ccc; padding: 24px;">
<table id="sqlResultsTable" class="styled-table" style="width: 100%;">
${thead}
${tbody}
</table>
</div>
<script>
window.jQuery = window.$ = jQuery;
$('#sqlResultsTable').DataTable( { "pageLength": 10, "lengthMenu": [ 10, 25, 50, 75, 100 ] } );
</script>
`;
}
The original author of the SuiteQL tool: Timothy Dietrich
I have a problem with changing the border color of table cell.
I've tried many times but it doesn't work.
please help me.
const theme = createTheme({
overrides: {
MuiTableCell: {
root: {
borderBottom: '1px solid #ff0000',
},
},
},
})
I tried above theme to table. but it doesn't work.
MuiTableCell: {
styleOverrides: {
head: {
borderBottom:"1px solid red"
},
body: {
borderBottom:"1px solid blue"
},
footer: {
borderBottom:"1px solid yellow"
},
}
}
I have a column where the style of each td needs to be changed based on value. There are five status's, so there has to be five different border-colors and font-colors. How do I do this in angular script without hard-coding (new to angular)?
What I am doing is:
In html:
<table st-table = "tenants" class="table table-striped table-bordered">
<tbody>
<tr dir-paginate="t in tenants | orderBy:sortColumn:reverseSort | filter:searchText | itemsPerPage:itemsPerPage" current-page="currentPage" >
<td ng-if="t.status.color==2"><b class = 'td_status'>{{t.status.id}}<b></td>
In css:
.td_status {
border-radius: 20px;
width: auto;
height: auto;
min-width: 100px;
display: inline-block;
text-align: center;
border: 1px solid red;
padding: 5px;
}
In js:
datax.forEach(function(obj,i){
if (obj.last_paid) {
if (obj.stripe_status == "active") {
obj.status = {
'id' : "Paid: Last Paid " + $filter('date')(obj.last_paid, 'MM-dd-yyyy'),
'value': "Paid: Last Paid " + $filter('date')(obj.last_paid, 'yyyy-MM-dd HH:mm:ss Z'),
'color' : 0
}
}
else if (obj.stripe_status == "past_due" || obj.stripe_status == "unpaid") {
obj.status = {
'id' : "Past Due: Last Paid " + $filter('date')(obj.last_paid, 'MM-dd-yyyy'),
'value': "Past Due: Last Paid " + $filter('date')(obj.last_paid, 'yyyy-MM-dd HH:mm:ss Z'),
'color' : 4,
}
}....
I made an example since it is a little slow at work.
Here you can see my use of ng-class. I give it a function and pass the status which is defined in $scope.data item.status comes from my ng-repeat
<div ng-app="TestApp" ng-controller="TestController">
<p ng-repeat="item in data" ng-class="getBorderColor(item.status)">
{{item.name}}
</p>
</div>
Below I have my controller and some sample data. The getBorderColor runs through its conditions and returns className based off of status.
var app = angular.module('TestApp', []);
app.controller('TestController', function($scope) {
$scope.data = [
{
name:'Ronnie',
status:1
},
{
name:'Chance',
status:2
},
{
name:'Mike',
status:1
},
{
name:'Mark',
status:3
}];
$scope.getBorderColor = function(status) {
var className = '';
if (status == 1) {
className = 'status1';
} else if (status == 2) {
className = 'status2';
} else if (status == 3) {
className = 'status3';
}
return className;
};
});
And my simple css is:
.status1 {
border:1px solid red;
}
.status2 {
border:1px solid blue;
}
.status3 {
border:1px solid green;
}
https://jsfiddle.net/ojzdxpt1/7/
I'm currently working on making a contacts editor but dont fully understand the knockout conditional css binding. Basically what i would like to have happen is when you click the Add employee button two text boxes are created to add a first and last name. I would like those fields to be highlighted using the knockout conditional css binding . I would like the same thing to happen when clicking the add number option.
here is my code
and a fiddle http://jsfiddle.net/grahamwalsh/c2fmnoub/
html
<div data-bind="if:!loaded()"> Loading...Please Wait</div>
<div class='NbiEmployees'data-bind="if:loaded()">
<h2>NBI Employees</h2>
<h3>NBI has <span data-bind="text: employees().length"></span> Employees</h3>
<div id='employeesList'>
<table class='employeesEditor'>
<tr>
<th>First name</th>
<th>Last name</th>
<th>Phone numbers</th>
</tr>
<tbody data-bind="foreach: employees">
<tr>
<td>
<input data-bind='value: firstName' />
<div><a href='#' data-bind='click: $root.removeEmployee'>Delete</a></div>
</td>
<td><input data-bind='value: lastName' /></td>
<td>
<table>
<tbody data-bind="foreach: phones">
<tr>
<td><input data-bind='value: type' /></td>
<td><input data-bind='value: number' /></td>
<td><a href='#' data-bind='click: $root.removePhone'>Delete</a></td>
</tr>
</tbody>
</table>
<a href='#' data-bind='click: $root.addPhone'>Add number</a>
</td>
</tr>
</tbody>
</table>
</div>
<p>
<button data-bind='click: addEmployee'>Add an Employee</button>
<button data-bind='click: save, enable: employees().length > 0'>Save to JSON</button>
</p>
<textarea data-bind='value: lastSavedJson' rows='5' cols='60' disabled='disabled'> </textarea>
css
body { font-family: arial; font-size: 14px; }
.NbiEmployees { padding: 1em; background-color: #EEEEDD; border: 1px solid #CCC; max-width: 655px; }
.NbiEmployees input { font-family: Arial; }
.NbiEmployees b { font-weight: bold; }
.NbiEmployees p { margin-top: 0.9em; margin-bottom: 0.9em; }
.NbiEmployees select[multiple] { width: 100%; height: 8em; }
.NbiEmployees h2 { margin-top: 0.4em; font-weight: bold; font-size: 1.2em; }
.NbiEmployees TR { vertical-align: top; }
.NbiEmployees TABLE, .NbiEmployees TD, .NbiEmployees TH { padding: 0.2em; border-width: 0; margin: 0; }
.NbiEmployees TD A { font-size: 0.8em; text-decoration: none; }
.NbiEmployees table.contactsEditor > tbody > TR { border-bottom: 1px solid silver; }
.NbiEmployees td input { width: 8em; }
li { list-style-type: disc; margin-left: 20px; }
Knockout
var EmployeesModel = function () {
var self = this;
self.employees = ko.observableArray(
);
self.loaded = ko.observable(false);
self.loadData = function loadData() {
self.loaded(false);
setTimeout(function () {
var data = [
{
firstName: "Graham", lastName: "Walsh", phones: [
{ type: "Office", number: "(555) 121-2121" },
{ type: "Mobile", number: "(555) 123-4567" }]
},
{
firstName: "Kimi", lastName: "Shirasaki", phones: [
{ type: "Office", number: "(555) 444-2222" },
{ type: "Mobile", number: "(555) 999-1212" }]
}
];
self.employees(ko.utils.arrayMap(data, function (employee) {
return {
firstName: employee.firstName,
lastName: employee.lastName,
phones: ko.observableArray(employee.phones)
};
}));
self.loaded(true);
}, 5000);
};
self.addEmployee = function () {
self.employees.push({
firstName: "",
lastName: "",
phones: ko.observableArray()
});
};
self.removeEmployee = function (employee) {
self.employees.remove(employee);
};
self.addPhone = function (employee) {
employee.phones.push({
type: "",
number: ""
});
};
self.removePhone = function (phone) {
$.each(self.employees(), function () { this.phones.remove(phone) })
};
self.save = function () {
self.lastSavedJson(JSON.stringify(ko.toJS(self.employees), null, 2));
};
self.lastSavedJson = ko.observable("")
self.loadData();
};
$(document).ready(function () {
ko.applyBindings(new EmployeesModel());
});
If you add something like this to the 'required' fields:
<input data-bind='value: firstName, css: {warn: !firstName()}' />
and then define your warn class:
.warn {
border-color: red;
}
then the field will be highlighted. However, for this to work, the fields have to be observable:
http://jsfiddle.net/c2fmnoub/14/
here, I've created an Employee() class with observable fields (except for the phone number, which can also be observable if needed), of which a new one needs to be created when calling the addEmployee() function
Edit: the phone number:
http://jsfiddle.net/c2fmnoub/16/
in the same way I defined an Employee object with observable fields, I defined a Phone object with observable fields. This should have been a simple extension for the OP to have done. I really hope I didn't just do your homework for you.
I am using "jquery.tablesorter.widgets.js" for Table filter working fine, but I have to display " No Data Found" when records not available based on Search Criteria.
Here is My Code.
HTML Code:
<tr>
<td class="filter-false" width="3%" style="background: #5e5c5c; color: #fff; vertical-align: middle; font-size: 12px; font-weight: bold"></td>
<th class="txt1" style="text-decoration: underline; cursor: pointer">Domain</th>
<th style="text-decoration: underline; cursor: pointer">Registrant Name</th>
<th class="filter-select" data-placeholder="Select" style="text-decoration: underline; cursor: pointer">Account Id</th>
<th style="text-decoration: underline; cursor: pointer">Expiry Date</th>
<th style="text-decoration: underline; cursor: pointer">Renewal Date</th>
<th style="text-decoration: underline; cursor: pointer">Email ID</th>
<th class="filter-false" style="text-decoration: underline; cursor: pointer">Status</th>
</tr>
Javascript Code:
$(document).ready(function () {
$("#yui").tablesorter({
// headers: { 0: { sorter: false }, 1: { sorter: false }, 2: { sorter: false }, 3: { sorter: false }, 4: { sorter: false }, 5: { sorter: false } },
widthFixed: false,
// initialize zebra striping and filter widgets
widgets: ["zebra", "filter"],
// headers: { 5: { sorter: false, filter: false } },
widgetOptions: {
// extra css class applied to the table row containing the filters & the inputs within that row
filter_cssFilter: '',
// visible; default is false
filter_childRows: false,
filter_ignoreCase: true,
filter_reset: '.reset',
filter_saveFilters: true,
filter_searchDelay: 300,
filter_startsWith: false,
filter_hideFilters: false,
filter_functions: {
}
}
})
.tablesorterPager({ container: $("#pagerOne"), positionFixed: false, size: 10 })
});
I have to display "No Data Found" message as row in table .
You can use the built-in showError function (v2.15+) and bind to a few events as follows (demo):
$(function () {
$("#yui")
.on('filterEnd filterReset pagerComplete', function(e, table){
var fr, table = this;
if (table.config.pager) {
$.tablesorter.showError(table);
fr = table.config.pager.filteredRows;
if (fr === 0) {
$.tablesorter.showError(table, "No Data Found");
}
}
})
.tablesorter({
theme: 'blue',
widthFixed: false,
widgets: ["zebra", "filter"],
widgetOptions: {
filter_cssFilter: '',
filter_childRows: false,
filter_ignoreCase: true,
filter_reset: '.reset',
filter_saveFilters: true,
filter_searchDelay: 300,
filter_startsWith: false,
filter_hideFilters: false,
filter_functions: {}
}
})
.tablesorterPager({
container: $(".pager"),
positionFixed: false,
size: 10
});
});
Note, the event binding needs to occur before the pager is initialized & the short setTimeout is also required because the pager filteredRows count is not updated immediately after the filterEnd event.
I need to fix the pagerChange event to ensure it fires after every pager change, not just a "page" change, so you would then only need to bind to one event that does not need a time delay
Update: Changed code to use the pagerComplete event, so no need for a setTimeout.