How to close dojox.grid.DataGrid - dojo

I have a grid that populates from a search event and I'd like the option of being able to close the grid by simply adding an X in the top right corner, similar to how you close any browser or window. I thought it would be as easy as adding the X, styling it to my liking and then creating an onclick event that would close or hide the grid... but I can't seem to get that working. Any help would be appreciated.
My JS is:
dojo.require("dojox.grid.DataGrid"); //FindTask
dojo.require("dojo.data.ItemFileReadStore"); //FindTask
dojo.require("esri.tasks.find"); //FindTask
var findTask, findParams;
var grid, store;
var searchExtent;
function doFind() {
//Show datagrid onclick of search button and resize the map div.
esri.show(datagrid);
dojo.style(dojo.byId("content"), "height", "83%");
searchExtent = new esri.geometry.Extent ({
"xmin":-9196258.30121186,"ymin":3361222.57748752,"xmax":-9073959.055955742,"ymax":3442169.390441412,"spatialReference":{"wkid":102100}
});
map.setExtent(searchExtent);
//Set the search text to the value in the box
findParams.searchText = dojo.byId("parcel").value;
grid.showMessage("Loading..."); //Shows the Loading Message until search results are returned.
findTask.execute(findParams,showResults);
}
function showResults(results) {
//This function works with an array of FindResult that the task returns
map.graphics.clear();
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98,194,204]), 2), new dojo.Color([98,194,204,0.5]));
//create array of attributes
var items = dojo.map(results,function(result){
var graphic = result.feature;
graphic.setSymbol(symbol);
map.graphics.add(graphic);
return result.feature.attributes;
});
//Create data object to be used in store
var data = {
identifier: "Parcel Identification Number", //This field needs to have unique values. USES THE ALIAS!!!
label: "PARCELID", //Name field for display. Not pertinent to a grid but may be used elsewhere.
items: items
};
//Create data store and bind to grid.
store = new dojo.data.ItemFileReadStore({ data:data });
var grid = dijit.byId('grid');
grid.setStore(store);
//Zoom back to the initial map extent
map.setExtent(searchExtent);
}
//Zoom to the parcel when the user clicks a row
function onRowClickHandler(evt){
var clickedTaxLotId = grid.getItem(evt.rowIndex).PARCELID;
var selectedTaxLot;
dojo.forEach(map.graphics.graphics,function(graphic){
if((graphic.attributes) && graphic.attributes.PARCELID === clickedTaxLotId){
selectedTaxLot = graphic;
return;
}
});
var taxLotExtent = selectedTaxLot.geometry.getExtent();
map.setExtent(taxLotExtent);
}
and my HTML is:
<div id ="datagrid" data-dojo-type="dijit.layout.AccordionPane" splitter="true" region="bottom"
style="width:100%; height:125px;">
<table data-dojo-type="dojox.grid.DataGrid" data-dojo-id="grid" id="grid" data-dojo-props="rowsPerPage:'5', rowSelector:'20px'">
<thead>
<tr>
<th field="Parcel Identification Number" width="10%">
Parcel ID
</th>
<th field="Assessing Neighbornood Code" width ="20%">
Neighborhood Code
</th>
<th field="Property Class Code" width="10%">
Property Class
</th>
<th field="Site Address" width="100%">
Address
</th>
</tr>
</thead>
</table>
</div>
This is my best guess at what to add:
<tr>
<td align="right">
<div class="divOk" onclick="dijit.byId('tocDiv').hide();">
OK</div>
</td>
</tr>

I wound up creating a work around for what I want by creating a new column and putting a close icon within the header. I connected it to an function so that when I click it, the grid closes and the map resizes:
function closeGrid() {
esri.hide(datagrid);
dojo.style("map", {"height": "100%"});
}
HTML
<th field="" width="2%"> <div class="GridCloseIcon" title="Close Grid" onclick="closeGrid();"></div>

How about this?
(assuming the OK line actually appears)
HTML
<tr>
<td align="right">
<div class="divOk" onclick="hideGrid();">OK</div>
</td>
</tr>
JS
function hideGrid() {
var widget = dijit.byId('datagrid');
dojo.fadeOut({
node: widget.domNode
}).play();
dojo.style(widget.domNode, 'display', 'none');
}

Related

Spring WebFlux+Thymeleaf How to display reactive collection size

I am developing a spring boot service to manage a REST server.
The service displays a reactive list on one of the forms.
It is very simple code.
Table in thymeleaf template
<table>
<thead>
<tr>
<td>ID</td>
<td>Name</td>
<td>Alive</td>
</tr>
</thead>
<tbody>
<tr th:each="item : ${items}">
<td th:text="${item.counterpartID}" />
<td th:text="${item.counterpartName}" />
<td th:text="${item.alive}"/>
</tr>
</tbody>
</table>
Controller
#GetMapping("/counterparties")
public String init(Model model) {
IReactiveDataDriverContextVariable reactiveDataDrivenMode =
new ReactiveDataDriverContextVariable(
webClient
.get()
.uri(uriBuilder -> uriBuilder
.path("/findAllCounterpart")
.build())
.retrieve()
.bodyToFlux(Counterpart.class)
, 1);
model.addAttribute("items", reactiveDataDrivenMode);
return "counterparties.html";
}
Now I want to display collection size (numbers of rows in table).
I added to the html temlate tag
<label th:text="'total rows: ' + ${#lists.size(items)}">rows number in table</label>
And I got an unexpected result
total rows: 1
How to display the real number of rows in a reactive collection ?
Thanks.
I decided to use javascript.
<script language="JavaScript">
function countLoadedRows() {
var table = document.getElementById('tableId');
var tbodyRowCount = table.tBodies[0].rows.length;
console.log('total rows: ' + tbodyRowCount);
document.getElementById('totalRowsId').textContent = tbodyRowCount
}
document.addEventListener('readystatechange', countLoadedRows)
</script>
and html tags is
<input type = "button" onclick = "countLoadedRows()" value = "Total rows: "><label id="totalRowsId">???</label>
<table id="tableId">
...
</table>

show/hide div on the bases of which box div clicked in Vuejs. check image for better understanding

This is an image of table i created(ignore dates in header)
Functionality I want
when a user click on a specific box dialog open and get some value which will decide whether to put tick or cross in that box. Let's say i clicked on a box in first column(27/07/2020) and third row(asdf)
then tick should be shown in that box.
Here is table I'm creating
<table class="table table-bordered">
<thead class="table_header">
<tr >
<th scope="col" class="text-center table_th" >Medications</th>
<template v-for="head in table_headers_data" >
<th scope="col" class="text-center table_th" >{{head.day}} {{head.date}}</th>
</template>
</tr>
</thead>
<tbody>
<template v-for="item in active_medications" >
<tr :key="item.uuid">
<th class="cust-border" scope="row">{{item.title}}</th>
<td v-for="(date_item, index) in table_headers_data" #click="boxClicked(item,date_item)" :key="index" >
//here is code where i am trying to show tick or cross on the basis of user input in that box and
<div v-show="selected_box==date_item.day+item.uuid+'-tick'" class="text-center" >
<v-icon color="green">mdi-check</v-icon>
<!-- <v-icon v-if="showCross==true" color="red">mdi-close</v-icon> -->
</div>
<div v-show="selected_box==date_item.day+item.uuid+'-cross'" class="text-center" >
<!-- <v-icon v-if="showTick==true" color="green">mdi-check</v-icon> -->
<v-icon color="red">mdi-close</v-icon>
</div>
</td>
</tr>
</template>
</tbody>
</table>
boxClicked function just get object of an item of medicine and data related to dates information.. then i store that data in firebase. problem i don't know how to show tick/cross in that specific box. its like a user take medicine or not on that date. if it takes medicine according to data i have to show tick or cross in that box corresponding to that medicine and date.
here is boxClicked function code
boxClicked(medicine,date_data){
this.checkbox_dialog = true;
this.administered_dialog = true;
this.medicine_detail.med_date = date_data.date;
const today = new Date();
//const date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
const time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
//const dateTime = date +' '+ time;
this.medicine_detail.med_time = time;
this.medicine_detail.med_day = date_data.day;
this.medicine_detail.med_uuid = medicine.uuid;
this.medicine_detail.user_email = this.user_email
/*console.log(this.medicine_detail)
let as = date_data.day+medicine.uuid;
console.log('as = '+as)*/
},
save_medicine_record function
this function is called when someone click on box and dialog open and user select it's value and click OK button . on click of OK button this function is called.
in the response of axios request i'm show tick/cross in that perticular box
save_medicine_record(status){
let api_token = this.user.api_token
axios.post('api/save_medicine_record?api_token='+api_token,this.medicine_detail)
.then(response => {
console.log('response = ')
console.log(response)
if(this.medicine_detail.status=='non_administered'){
console.log('in respose cross')
this.selected_box=this.medicine_detail.med_day+this.medicine_detail.med_uuid+'-cross'
// this.showCross = true;
}
else if(this.medicine_detail.status=='administered'){
console.log('in respose tick')
this.selected_box=this.medicine_detail.med_day+this.medicine_detail.med_uuid+'-tick'
//this.showTick = true;
}
//this.table_headers_data=[];
})
.catch(err=>{
console.log(err)
/*this.snackbar_error = true
this.snackbar_text = err.response.data.message*/
})
},
I tried to give id to the div in like :id="date_item.day+item.uuid"
and other way i tried is in above code.
Everything is working fine when i store data in firebase and get result from axios i want to put tick or cross in that specific location..
Problem now facing
after many tries i am able to show tick/cross on the basis of user input but then when i try to enter value in other box then it removes previous clicked box and show just one box value(tick/cross icon div).
I also tried to create data variables dynamically in a thinking to give that v-if true and false. but unable to reach that point.
Please please guide me how to achieve functionality because i spent many days on it.
I posted this question 10 days ago but did not get any solution so that is why i am posting it again
Pics of dialogs when a box is clicked
Use an array of selected boxes, Try this for tick and same for cross
//you can use a Map() [--dictionary] object here
this.selected_box_array.push(this.medicine_detail.med_day+this.medicine_detail.med_uuid+'-tick')
<!-- <v-icon v-if="showTick==true && selected_box_array.indexOf(date_item.day+item.uuid+'-tick')" color="green">mdi-check</v-icon> -->

Display the first row of view data in razor

I have a a ViewData with 8 rows. The ForEach loop works fine, but I need to extract the very first row before the foreach.
I need to extract only the first row to inject the default video in the iframe.
<iframe name="myFrame" width="800" height="500" src="#item.ID?wmode=transparent" allowfullscreen="True"></iframe>
Here is the foreach that works 100%
#foreach (var item in (List<VideoModel>)ViewData["Videos"])
{
<tr class="sep">
<td>#item.DisplayNumber</td>
<td>
#Html.ActionLink("Play Video", "IframeRedirect", "Home", new { ContentID = item.ID }, new { target = "someFrame", #class = "cbutton" })
</td>
<td>#item.Time #item.Hd</td>
<td><b>#item.Title</b><br />#item.Description</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td><b>Author:</b> #item.Author <br />Subscribe to youtube channel</td>
</tr>
}
you can get the first row like following:
var firstRow = ((List<VideoModel>)ViewData["Videos"]).First();
If your model is a IEnumerable
You can get the first like following:
var first = Model.First();

how to create cart content as pdf output in PRESTASHOP

I have to print the cart content in a pdf file and download.
I have try some code using pdfinvoicecontroller.php
I have created new controller - controllers/front/CartprintController.php
class CartprintControllerCore extends FrontController
{
protected $display_header = false;
protected $display_footer = false;
public $content_only = true;
protected $template;
public $filename;
public function postProcess()
{
if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key'))
Tools::redirect('index.php?controller=authentication&back=cartprint');
}
public function display()
{
$displayproducts = $this->context->cart->getProducts();
$pdf = new PDF($displayproducts, PDF::TEMPLATE_INVOICE_CART, $this->context->smarty, $this->context->language->id);
$pdf->render();
}
public function getTemplate()
{
$template = _PS_THEME_PDF_DIR_.'/cartprint.tpl';
return $template;
}
}
Added
const TEMPLATE_INVOICE_CART = 'Cartprint';
line in classes/pdf/PDF.php
3.then created a HTML template file in pdf/cartprint.tpl
<table id="cart_summary" class="std">
<thead>
<tr>
<th class="cart_product first_item">{l s='Product'}</th>
<th class="cart_description item">{l s='Description'}</th>
<th class="cart_unit item">{l s='Unit price'}</th>
<th class="cart_quantity item">{l s='Qty'}</th>
<th class="cart_total item">{l s='Total'}</th>
</tr>
</thead>
{foreach $displayproducts item=prodpef name=prodpef }
<tr>
<td class="cart_product first_item">{$prodpef.name}</td>
<td class="cart_description item">{$prodpef.description_short}</td>
<td class="cart_unit item">{$prodpef.price}</td>>
<td class="cart_quantity item">{$prodpef.cart_quantity}</td>>
<td class="cart_total item">{$prodpef.total}</td>>
</tr>
{/foreach}
</table>
4.in shopping cart page i have created a link
<img src="{$img_dir}icon/pdf.gif" alt="{l s='Invoice'}" class="icon" />
but still i am not getting pdf output .
Any help ?
First it will be better to override PDF class and second you need to create a HTMLTemplateCartPrint.php file in classes dir or override classes dir in order to generate pdf file.
Best regards.

How to dynamically add a hyperlink (BookmarkablePageLink) to DefaultDataTable that is rendered as an anchor

I have a DefaultDataTable that gets its columns programmatically.
The markup is simple:
<table wicket:id="dataTable" border="0" cellpadding="1" cellspacing="1" width="90%" />
All of the columns are dynamically generated from a passed in LinkedHashMap of labels and attributes:
for (Entry<String, String> entry : entrySet) {
final String label = entry.getKey();
final String attribute = entry.getValue();
columns.add(new PsPropertyColumn(label, attribute) {
#Override
public void populateItem(Item cellItem, String componentId, IModel model)
{
final Object modelObject = model.getObject();
final Object value = PropertyResolver.getValue(attribute, modelObject);
// Add an edit link
BookmarkablePageLink link = new ...;
...
cellItem.add(link);
}
}
}
DefaultDataTable table = new DefaultDataTable("dataTable", columns, dataProvider, MAX_ROWS) {
...
}
add(table);
As many posts have mentioned, this is rendered as a cell with an onclick handler rather than an anchor (<a href="..." />) tag. I want the anchor tag for a couple of reasons, one if which is that I want to add my own onclick handler without having an existing onclick handler in the way.
I have seen the generally accepted solution that says to put an anchor tag inside a panel in the HTML markup, and to add the link inside of a Panel subclass. However, that doesn't give the entire html markup (inside the table), and I think the column () tags must be a part of this markup, which I don't think works with my strategy of dynamically generating the columns (I don't even know or care how many will be asked for). Is there a way to render my dynamically generated columns as anchor tags without specifying in the markup how many there?
Thank you for any help.
I have used nested ListView components to be able to have more control over the layout as below:
html:
<table wicket:id="listViewContainer">
<tr>
<th wicket:id="columnHeaderListView">
<span wicket:id="columnHeaderLabel">Header Label</span>
</th>
</tr>
<tr wicket:id="rowListView">
<td wicket:id="rowColumnListView">
<a href="#" wicket:id="link">
<span wicket:id="linkLabel">Link Label</span>
</a>
</td>
</tr>
</table>
Java:
WebMarkupContainer listViewContainer = new WebMarkupContainer("listViewContainer");
listViewContainer.setOutputMarkupId(true);
add(listViewContainer);
ListView columnHeaderListView = new ListView("columnHeaderListView", columnHeaderList) {
#Override
protected void populateItem(ListItem listItem) {
ColumnHeader ch = (ColumnHeader) listItem.getModelObject();
listItem.add(new Label("columnHeaderLabel", new Model(ch.getLabel())));
}
};
listViewContainer.add(columnHeaderListView);
ListView rowListView = new ListView("rowListView", rowList) {
#Override
protected void populateItem(ListItem listItem) {
Row row = (Row) listItem.getModelObject();
listItem.add(new ListView("rowColumnListView", getRowColumnList(row)){
#Override
protected void populateItem(ListItem li) {
RowColumn rowColumn = (RowColumn) li.getModelObject();
Link link = new BookmarkablePageLink("link",...
li.add(link);
link.add(new Label("linkLabel", new Model(rowColumn.getLabel())));
}
});
}
}
listViewContainer.add(rowListView);