I don't know how to get values from tables that don't have an ID.
I would like to use DOM to get the value "03" from
<tr><th scope='row'>Total WUs</th><td>03</td></tr>
but the table doesn't have an ID. It is the first table on the page. I'll give a code printout of the whole table:
<table cellspacing='0' rules='all' border='1' style='border-collapse:collapse;'><tr><th scope='row'>User Name</th><td>laughing_squid</td></tr><tr><th scope='row'>Project Rank</th><td>1,156,036</td></tr><tr><th scope='row'>Team Rank</th><td>2</td></tr><tr><th scope='row'>Total Points</th><td>207</td></tr><tr><th scope='row'>Total WUs</th><td>03</td></tr><tr><th scope='row'>Points Yesterday</th><td>NA</td></tr><tr><th scope='row'>Points Today</th><td>69</td></tr><tr><th scope='row'>PPD Average</th><td>138</td></tr></table>
Check this out, this script uses JQuery which can be downloaded from here:
$('table td').each(function(){
console.log($(this).text());
});
if you need only the value 03 then use following:
console.log($('table td:eq(4)').text());
Related
I need to add data-test attribute to column header for automated testing of different operations, such as sorting, filtering etc., so that scripts could find where to click.
How it can be done? I would like to keep all the functionality of default headers, just add the attribute.
Thanks!
You can use the renderHeader and pass the attributes you want like below:
columns={[
{
field: "name",
renderHeader: (params) => (
<span data-testid="header-test-id"> // Here pass your data-testid
{"Header with attr "}
</span>
)
}
]}
I am working with the ag-grid rowDrag capabilities and would like to enable and disable rowDrag based on the data in each row. It looks like rowDrag can contains a condition, but its unclear how to access the fields.
<AgGridColumn field="myOffer" rowDrag={fieldMyOffer === 'test' ? rowDrag : undefined} />
It is possible to dynamically control which rows are draggable by providing a callback function as shown below:
const athleteRowDrag = params => params.data.athlete === "Michael Phelps";
<AgGridReact>
<AgGridColumn field="athlete" rowDrag={athleteRowDrag} />
</AgGridReact>
Documentation on Row Dragging
I would like to add to Shuheb's answer, since I ran into this:
If the cell you are checking is BLANK
rowDrag: params => params.data.type === "",
will not work. You have to do:
rowDrag: params => params.data.type.length > 1,
Ag-grid seems to insert a space in there somewhere so checking for an empty string or checking that length > 0 doesn't work. I spent several hours trying to get this to work.
Might file a git issue on this one, as my data clearly shows it's an empty string.
I have a postgres table in which I have some "defaulted" fields like date_created which automatically receives a current_timestamp as default.
or the ID field which gets it's value from a sequence defined in the database.
What would be (if possible) the syntax to tell the ORM module to not include these two fields when generating an INSERT statement ?
You can use a function as 2nd parameter to remove the fields:
$this->copyfrom('POST',function($val) {
unset($val['ID']);
unset($val['date_created']);
return $val
});
or to only copy allowed fields from the POST array:
$this->copyfrom('POST',function($val) {
return array_intersect_key($val, array_flip(array('name','age')));
});
Assuming you are using an HTML form to add new records into the tables, follow the steps below;
In the form, omit these 'defaulted' fields, i.e. add only the fields that you want to submit
Create a model with a function similar to below
public function add() {
$this->copyFrom ( 'POST' );
$this->save ();
}
Create a route that links the form to this function
I need to retrieve only part of a document and call it via a helper so that I can render a subtemplate multiple times as the part I require to pull from the db is an array of object itself. I have the following as the fields. What I need to do with my helper is only retrieve the ordersDispatch array of one particular document which would be uniquely called by the tripNumber field.
I have tried several things but nothing has come close to only having an array of the objects in the orderDisptach field be returned in a fashion that it can be used by the helper to render my subtemplate for each object in the array.
{
tripNumber: companyRecord.lastTripNum + 1,
custID: $('input:hidden[name=orderCustomerId]').val(),
custContact: $('input:text[name=customerContact]').val(),
custEmail: $('input:text[name=customerEmail]').val(),
trailerSealNum: $('input:text[name=trailerSealNum]').val(),
orderBroker: $('input:text[name=orderBroker]').val(),
orderEquipment: $('input:text[name=orderEquipment]').val(),
orderLoadNum: $('input:text[name=orderLoadNum]').val(),
orderPlacedDate: $('input:text[name=orderPlacedDate]').val(),
orderPrivateNotes: $('textarea[name=orderPrivateNotes]').val(),
orderPublicNotes: $('textarea[name=orderPublicNotes]').val(),
orderCurrency: $("input[name=orderCurrency]:checked").val(),
orderCharges: $('input:text[name=orderCharges]').val(),
orderFUELCheck: $('input:checkbox[name=orderFUELCheck]').is(':checked'),
orderFUELPerc: $('input:text[name=orderFUELPerc]').val(),
orderFUELTotal: $('input:text[name=orderFUELTotal]').val(),
orderGSTCheck: $('input:checkbox[name=orderGSTCheck]').is(':checked'),
orderGSTPerc: $('input:text[name=orderGSTPerc]').val(),
orderGSTTotal: $('input:text[name=orderGSTTotal]').val(),
orderPSTCheck: $('input:checkbox[name=orderPSTCheck]').is(':checked'),
orderPSTPerc: $('input:text[name=orderPSTPerc]').val(),
orderPSTTotal: $('input:text[name=orderPSTTotal]').val(),
orderTAXCheck: $('input:checkbox[name=orderTAXCheck]').is(':checked'),
orderTAXPerc: $('input:text[name=orderTAXPerc]').val(),
orderTAXTotal: $('input:text[name=orderTAXTotal]').val(),
orderTotalCharges: $('input:text[name=orderTotalCharges]').val(),
ordeBlockInvoicing: $('input:checkbox[name=ordeBlockInvoicing]').is(':checked'),
orderExtraCharges: orderExtraCharges,
orderPickups: puLocations,
orderDeliveries: delLocations,
orderDispatch: dispatchLocations,
createdDate: new Date(),
createdUser: currentUser.username
Any help in building a helper that will accomplish this would be greatly appreciated as I am new to meteor and mongo.
The following helper should give you what you need:
Template.oneTrip.helpers({
orderDispatch: function(tn){
return Trips.findOne({ tripNumber: tn }).orderDispatch;
}
});
Trips.findOne({ tripNumber: tn }) gets you an individual document and .orderDispatch returns the value of the orderDispatch key which in your case will be an array.
html:
<template name="oneTrip">
{{#each orderDispatch this._id}} <!-- assuming you've already set the data context to an individual order -->
{{this}} <!-- now the data context is an element of the orderDispatch array -->
{{/each}}
</template>
In zend project I fetch data from the database and show in a table. It shows data in the same order as stored in the database. But I want to show the fileds in diffeent order than in database order. But I don't know how to do thid. Here I means field order not the row order.
Please help me in this regard.
Thanks
Its hard to say how youre displaying but lets assume you have made Table Classes for each table i would do something like this:
<?php foreach $zendDbRowObject->getTable()->getDisplayOrder() as $fieldName): ?>
<?php echo $zendDbRowObject->$fieldName; ?>
<?php endforeach; ?>
So then in your Table clas for a particular table you can create a property/method to get the fields in the order you want them in:
public function getDisplayOrder() {
// fake column names obviously... use yours here.
return array(
'column5',
'column1',
'column4',
'column2',
'column3'
);
}
when you do db select, you can select the coloumns that you want, so instead of select *,
you do select col5,col3,col2,col6,col1 from tablename
This will change the order of the columns
$select = $db->select()
->from(array('t' => 'table'),
array('t.col2', 'p.col1`'));