We need to provide some identifier for our react components so that we can do the automation test case writing on those controls.
import React from 'react';
import ReactDOM from 'react-dom';
import { Grid, GridColumn as Column } from '#progress/kendo-react-grid';
import products from './products.json';
class App extends React.Component {
state = {
gridData: products
}
render() {
return (
<div>
<Grid
data-grid="myGrid"
style={{ height: '400px' }}
data={this.state.gridData}
>
<Column field="ProductID" title="ID" width="40px" />
<Column field="ProductName" title="Name" width="200px" />
<Column field="Category.CategoryName" title="CategoryName" />
<Column field="UnitPrice" title="Price" width="80px" />
<Column field="UnitsInStock" title="In stock" width="80px" />
<Column field="Discontinued" width="120px"
cell={(props) => (
<td>
<input disabled type="checkbox" checked={props.dataItem[props.field]} />
</td>
)} />
</Grid>
</div>
);
}
}
ReactDOM.render(
<App />,
document.querySelector('my-app')
);
We have tried to provide data-grid="myGrid" attribute to the grid but that doesn't seems to work. Could you please suggest what is the mistake here or what will be the solution.
You should pass prop using camelCase so it should be like this:
<Grid dataGrid="myGrid" />
And inside Grid you can specify it like this:
const Grid = ({dataGrid}) => (
<div data-grid={dataGrid} />
)
Or you can just set id to the component <Grid id="myGrid" />
Related
I have a SAPUI5 responsive table with multi-select mode. And I need to show the selected records when loading data to the table. Couldn't find a way to set selected records in the responsive table.
<Table id="idProductsTable"
inset="false"
mode="MultiSelect"
alternateRowColors="true"
items="{
path: '/ProductCollection',
sorter: {
path: 'Name'
}
}">
<headerToolbar>
<OverflowToolbar>
<Title text="Products" level="H2"/>
<ToolbarSpacer/>
<Label text="Multi selection modes" labelFor="idComboBoxSuccess"></Label>
<ComboBox id="idComboBoxSuccess" selectedKey="Default" selectionChange=".onSelectionChange">
<core:Item text="Default" key="Default"></core:Item>
<core:Item text="ClearAll" key="ClearAll"></core:Item>
</ComboBox>
</OverflowToolbar>
</headerToolbar>
<columns>
<Column width="12em">
<Text text="Product" />
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="Supplier" />
</Column>
<Column minScreenWidth="Tablet" demandPopin="true" hAlign="End">
<Text text="Dimensions" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier
title="{Name}"
text="{ProductId}"/>
<Text
text="{SupplierName}" />
<Text
text="{Width} x {Depth} x {Height} {DimUnit}" />
</cells>
</ColumnListItem>
</items>
</Table>
Is there a way to set the selected rows in the table and display selected records.
You can use selected property in ColumnListItem.
<ColumnListItem selected="{YourSelectedBoolean}">
<cells>
<ObjectIdentifier title="{Name}" text="{ProductId}"/>
<Text text="{SupplierName}" />
<Text text="{Width} x {Depth} x {Height} {DimUnit}" />
</cells>
</ColumnListItem>
Fiddle
I have an app that has been running fine until we migrated to WAS9 app server(which uses jsf2.2 by default).
The app has a composite component which contains a primefaces:autosuggest widget. The widget stopped "firing" the itemSelect event. The ajaxListener is never firing.
Everything I see says that it is coded correctly, but nothing.
I have tried adding the "change" event, but that event also never fires.
The only thing I have been able to make work is to make it a regular listener
<cc:attribute name="ajaxLocationListener" method-signature="void listener()"/>
but then I do not have access to the data on the event that I need.
This is the implementation of the composite component:
<com:stopComponent id="Origin"
customerKey="#{templateController.ordrBeanUI.orderHeaderUI.customerUniqueKey}"
stop="#{templateController.ordrBeanUI.orderStopListUI.orderStopList[0]}"
options="#{templateController.custOptionsBean.countryCodesBean}"
mode="#{templateController.ordrBeanUI.orderHeaderUI.shippingMode}"
intlModeFlag="#{templateController.ordrBeanUI.orderHeaderUI.intlModeFlag}"
docType="#{templateController.ordrBeanUI.orderHeaderUI.documentType}"
addressBookAction="#{templateController.addressBookLookUp}"
saveAddressAction="#{templateController.saveAddressBook}"
lookAheadAction="#{templateController.obtainLocationList}"
ajaxListener="#{templateController.handleSelect}"
>
<f:ajax execute="Origin" render="originPanel" onevent="setOrderFieldFlagsAjax"/>
</com:stopComponent>
The actual StopComponent is here:
<html xmlns:x="http://www.w3.org/1999/xhtml"
xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:lf="http://websphere.landstar.com/jsf"
xmlns:com="http://xmlns.jcp.org/jsf/composite/components">
<cc:interface displayName="locationSection">
<cc:attribute name="customerKey" type="java.lang.Integer" />
<cc:attribute name="stop" type="com.landstar.cust.orders.beans.OrderStopUI" required="true" />
<cc:attribute name="options" type="com.landstar.cust.orders.beans.CountryCodesSelectOptionsBean" required="true" />
<cc:attribute name="mode" type="java.lang.String" required="true" />
<cc:attribute name="intlModeFlag" type="java.lang.Boolean" required="true" />
<cc:attribute name="docType" type="java.lang.String" />
<cc:attribute name="addressBookAction" method-signature="void actionListener(javax.faces.event.AjaxBehaviorEvent)" required="true"/>
<cc:attribute name="saveAddressAction" method-signature="void actionListener(javax.faces.event.ActionEvent)" />
<cc:attribute name="lookAheadAction" method-signature="java.util.List obtainAddress(java.lang.String)" />
<cc:attribute name="ajaxListener" method-signature="void actionListener(javax.faces.event.AjaxBehaviorEvent)" />
<cc:clientBehavior name="click" event="action" targets="saveLink" />
<cc:clientBehavior name="itemSelect" event="itemSelect" targets="stopLocationID stopLocationName" />
<cc:clientBehavior name="dateSelect" event="dateSelect" targets="#{cc.clientId}_fromDate #{cc.clientId}_toDate" />
</cc:interface>
<p:autoComplete id="stopLocationName" value="#{cc.attrs.stop.selectedLocationName}" minQueryLength="3"
completeMethod="#{cc.attrs.lookAheadAction}" forceSelection="false"
var="p" itemLabel="#{p.locationText}" itemValue="#{p}" size="32" maxlength="30"
converter="locationConverter">
<f:attribute name="customerKey" value="#{cc.attrs.customerKey}" />
<f:attribute name="searchType" value="locationName" />
<f:attribute name="mode" value="#{cc.attrs.mode}" />
<f:attribute name="geoType" value="#{cc.attrs.stop.stopInternational}" />
<f:attribute name="stopType" value="#{cc.clientId}"/>
<p:ajax event="itemSelect" listener="#{cc.attrs.ajaxLocationListener}" update="stopComponent" oncomplete="setOrderFieldFlagsPrimeFaces(xhr,status,args)" />
</p:autoComplete>
The Backing Bean is here:
#ManagedBean(name="orderController")
#ViewScoped
public class OrderController extends DocumentController implements Serializable {
}
public class DocumentController extends DateTimeConversions implements Serializable {
...
public void handleSelect(SelectEvent event) {
String stopType = event.getComponent().getClientId();
String calledFrom = "lookAhead";
populateLocationFromAddressBook(stopType, calledFrom,
((LocationLookAheadBean) event.getObject()).getLocationAddressUniqueKey());
String stopTypeStr = "";
if (stopType != null && !stopType.trim().equals("")) {
stopTypeStr = stopType.trim().substring(0, stopType.trim().indexOf(":"));
}
RequestContext context = RequestContext.getCurrentInstance();
context.addCallbackParam("location", stopTypeStr);
}
}
I am using MUIDatatables and the table is not responsive to the window screen. I want the table to always have one line per row, and use horizontal scroll.
I have tried putting the table inside a Material UI Grid component and Grid Component but that isn't working or I might not be configuring it correctly.
This is where I house all my components
<ThemeProvider theme={theme}>
<div className={classes.root}>
<CssBaseline />
<nav className={classes.drawer}>
<Hidden xsDown implementation="js">
<Navigator open={this.state.drawerOpen} PaperProps={{ style: { width: drawerWidth } }} />
</Hidden>
</nav>
<div className={classes.appContent}>
<Header onDrawerToggle={this.handleDrawerToggle} />
<main className={classes.mainContent}>
<div>
<Switch>
<Route exact path="/EditContracts/:contractId/sections/:section" component={EditSection} />
<Route exact path="/EditContracts/:contractId" component={EditContract} />
<Route exact path="/EditUsers/:userId" component={EditUser} />
<Route exact path="/EditEndpoints/:epId" component={EditEndpoint} />
<Route exact path="/EditTunnels/:tunnel_id" component={EditTunnel} />
<Route exact path="/EditContracts/:contractId/addSection" component={CreateSection} />
<Route exact path="/Contracts/List" component={Contracts} />
<Route exact path="/Contracts/Create" component={CreateContract} />
<Route exact path="/Tunnel_Profiles/Create" component={CreateTunnel} />
<Route exact path="/Contracts/Import" component={ImportContract} />
<Route exact path="/Users/List" component={Users} />
<Route exact path="/Tunnel_Profiles/List" component={TunnelProfiles} />
<Route exact path="/Users/Create" component={CreateUser} />
<Route exact path="/Endpoints/Create" component={CreateEndpoint} />
<Route exact path="/Endpoints/List" component={Endpoints} />
<Route exact path="/Community" component={PugCommunity} />
<Route exact path="/Connections" component={Connections} />
<Route exact path="/Dashboard" component={Dashboard} />
<Route exact path="/Alerts" component={Alerts} />
<Route exact path="/System_Setup/Organization" component={Organization} />
<Redirect exact from="/System_Setup" to="/System_Setup/Organization" />
<Redirect exact from="/Users" to="/Users/List" />
<Redirect exact from="/Tunnel_Profiles" to="/Tunnel_Profiles/List" />
<Redirect exact from="/Endpoints" to="/Endpoints/List" />
<Redirect exact from="/Contracts" to="/Contracts/List" />
</Switch>
</div>
</main>
</div>
</div>
</ThemeProvider>
</div>
How I have table set up
<Grid container direction='row'>
<Grid item>
<MUIDataTable data={data123} columns={columns123} options={options}/>
</Grid>
</Grid>
This is how I solved it.
<div style={{display: 'table', tableLayout:'fixed', width:'100%'}}>
<MuiThemeProvider theme={this.getMuiTheme()}>
<MUIDataTable data={data123} columns={this.state.columns} options={options}/>
</MuiThemeProvider>
</div>
looking for some code that I could add in to my reactjs app that will present users with an error when accessing my app using Firefox.... Something like Browser Type is not supported.
import './App.css';
import { BrowserRouter as Router, Route, Link, Switch, Redirect } from 'react-router-dom';
import Home from './components/Home';
import Test from './components/Test';
import Test1 from './components/Test1';
class App extends Component {
render() {
return (
<Router>
<div>
<Navbar />
<Switch>
<Route exact path="/" component={Home} /> <Route exact path="/home" component={Home} /> <Route exact path="/test" component={Test} /> <Route exact path="/test1" component={Test1} />
<Route component={NoMatch} />
</Switch>
</div>
</Router>
);
}
}
export default App;
Online I see some bits but I'm unsure where if should be added in to my app.jsx or my index.html or index.jsx......
Looking for someone that might have an example for me please
try this
import './App.css';
import { BrowserRouter as Router, Route, Link, Switch, Redirect } from 'react-router-dom';
import Home from './components/Home';
import Test from './components/Test';
import Test1 from './components/Test1';
class App extends Component {
render() {
if(navigator.userAgent.indexOf("Firefox") > 0) {
return <div>Browser not supported </div>
}
return (
<Router>
<div>
<Navbar />
<Switch>
<Route exact path="/" component={Home} /> <Route exact path="/home" component={Home} /> <Route exact path="/test" component={Test} /> <Route exact path="/test1" component={Test1} />
<Route component={NoMatch} />
</Switch>
</div>
</Router>
);
}
}
export default App;
this is how my view file looks like:
<mvc:View
controllerName="abc"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:form="sap.ui.layout.form"
xmlns:l="sap.ui.layout" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
xmlns:core="sap.ui.core">
<App>
<pages>
<Page title="APP_TITLE" showHeader="false">
<content>
<Table id="configTable" mode="None" items="{ path : '/'}">
<columns>
<Column id="bname">
<Text text="BOOKING_NAME"></Text>
</Column>
<Column> <Button icon="sap-icon://message-information" text="Info" type="Emphasized" press="handleMessagePopoverPress"/>
</Column>
<Column hAlign="Right" id="addItem" width="2em"></Column>
</columns>
</Table>
</content>
<footer>
<Toolbar class="sapContrast sapContrastPlus" width="100%">
</Toolbar>
</footer>
</Page>
</pages>
</App>
which will produce the following UI:
as you can see that button just destroys the whole column, there is a lot of space under BOOKING_NAME how can I adjust the size of the button to the column so it doesn't scratch everything? if that's not possible how can I align the text to the center of the column, I tried vAlign="Middle" but nothing changed..... I don't find anything in the sapui5 doc
actually just solved this by adding another column in that layout and instead of using an button and icon I just implemented the icon
<mvc:View
controllerName="local.controller"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:form="sap.ui.layout.form"
xmlns:l="sap.ui.layout" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
xmlns:c="sap.ui.core">
and between the colum the following:
<c:Icon src="sap-icon://message-information" size="1em" id="infoDefaultCurrency" press="onInfoButtonPressed" />
Simple workaround will be using css.You can use sapui5 predefined margin class for this.
jQuery.sap.require("sap.m.MessageToast");
sap.ui.controller("local.controller", {
doSomething: function() {
sap.m.MessageToast.show("Hello UI5 World");
}
});
var oModel = new sap.ui.model.json.JSONModel({
people: [{
name: 'Joseph',
number: 1.618
},
{
name: 'DJ',
number: 0
}
]
});
var oView = sap.ui.xmlview({
viewContent: jQuery('#view1').html()
});
oView.setModel(oModel);
oView.placeAt('content');
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8">
<title>MVC with XmlView</title>
<script src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.m"></script>
<script id="view1" type="sapui5/xmlview">
<mvc:View controllerName="local.controller" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m">
<App>
<pages>
<Page title="APP_TITLE" showHeader="false">
<content>
<Table id="configTable" mode="None" items="/people">
<columns>
<Column id="bname">
<Text text="BOOKING_NAME" class="sapUiSmallMarginTop"></Text>
</Column>
<Column>
<Button icon="sap-icon://message-information" text="Info" type="Emphasized" press="handleMessagePopoverPress" />
</Column>
<Column hAlign="Right" id="addItem" width="2em"></Column>
</columns>
</Table>
</content>
<footer>
<Toolbar class="sapContrast sapContrastPlus" width="100%">
</Toolbar>
</footer>
</Page>
</pages>
</App>
</mvc:View>
</script>
</head>
<body class='sapUiBody'>
<div id='content'></div>
</body>
</html>
I have used sapUiSmallMarginTop in the sample