-
Notifications
You must be signed in to change notification settings - Fork 0
/
ac9c73c7.89879ff2.js
1 lines (1 loc) · 7.06 KB
/
ac9c73c7.89879ff2.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[56],{129:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return o})),n.d(t,"metadata",(function(){return c})),n.d(t,"toc",(function(){return i})),n.d(t,"default",(function(){return d}));var r=n(3),a=(n(0),n(165)),l=(n(179),n(177));const o={id:"selected-row",title:"Selected Row",hide_title:!0},c={unversionedId:"style/selected-row",id:"style/selected-row",isDocsHomePage:!1,title:"Selected Row",description:"Styling Selected Row",source:"@site/demos/style/selected-row.mdx",slug:"/style/selected-row",permalink:"/demos/style/selected-row",version:"current",sidebar:"sidebar",previous:{title:"Row",permalink:"/demos/style/rows"},next:{title:"Basic Tree Data",permalink:"/demos/tree-data/basic"}},i=[{value:"Props",id:"props",children:[]},{value:"Usage",id:"usage",children:[]},{value:"Live Demo",id:"live-demo",children:[]}],s={toc:i};function d(e){let{components:t,...n}=e;return Object(a.b)("wrapper",Object(r.a)({},s,n,{components:t,mdxType:"MDXLayout"}),Object(a.b)("h1",{id:"styling-selected-row"},"Styling Selected Row"),Object(a.b)("h2",{id:"props"},"Props"),Object(a.b)("table",null,Object(a.b)("thead",{parentName:"table"},Object(a.b)("tr",{parentName:"thead"},Object(a.b)("th",{parentName:"tr",align:null},"Field"),Object(a.b)("th",{parentName:"tr",align:null},"Type"),Object(a.b)("th",{parentName:"tr",align:null},"Description"))),Object(a.b)("tbody",{parentName:"table"},Object(a.b)("tr",{parentName:"tbody"},Object(a.b)("td",{parentName:"tr",align:null},Object(a.b)("inlineCode",{parentName:"td"},"options.rowStyle")),Object(a.b)("td",{parentName:"tr",align:null},"style object or func"),Object(a.b)("td",{parentName:"tr",align:null},"style to apply in all rows cells")),Object(a.b)("tr",{parentName:"tbody"},Object(a.b)("td",{parentName:"tr",align:null},Object(a.b)("inlineCode",{parentName:"td"},"onRowClick")),Object(a.b)("td",{parentName:"tr",align:null},"func"),Object(a.b)("td",{parentName:"tr",align:null},"to handle row click (event, rowData)")))),Object(a.b)("h2",{id:"usage"},"Usage"),Object(a.b)("pre",null,Object(a.b)("code",{parentName:"pre",className:"language-jsx"},'import MaterialTable from "@material-table/core";\n\n<MaterialTable\n // ...\n onRowClick={(evt, selectedRow) => setSelectedRow(selectedRow.tableData.id)}\n options={{\n rowStyle: (rowData) => ({\n backgroundColor:\n selectedRow === rowData.tableData.id ? "#6ABAC9" : "#FFF",\n }),\n }}\n/>;\n')),Object(a.b)("h2",{id:"live-demo"},"Live Demo"),Object(a.b)(l.a,{mdxType:"InfoBannerAboutGlobalVarsInDemos"}),Object(a.b)("pre",null,Object(a.b)("code",{parentName:"pre",className:"language-jsx",metastring:"live",live:!0},'function StyledSelectedRow() {\n const [selectedRow, setSelectedRow] = React.useState(null);\n\n return (\n <MaterialTable\n data={[\n {\n name: "Mehmet",\n surname: "Baran",\n birthYear: 1987,\n birthCity: 63,\n },\n {\n name: "Zerya Bet\xfcl",\n surname: "Baran",\n birthYear: 2017,\n birthCity: 34,\n },\n ]}\n columns={[\n {\n title: "Name",\n field: "name",\n },\n { title: "Surname", field: "surname" },\n { title: "Birth Year", field: "birthYear", type: "numeric" },\n {\n title: "Birth Place",\n field: "birthCity",\n lookup: { 34: "\u0130stanbul", 63: "\u015eanl\u0131urfa" },\n },\n ]}\n onRowClick={(evt, selectedRow) =>\n setSelectedRow(selectedRow.tableData.id)\n }\n options={{\n rowStyle: (rowData) => ({\n backgroundColor:\n selectedRow === rowData.tableData.id ? "#6ABAC9" : "#FFF",\n }),\n }}\n />\n );\n}\n')))}d.isMDXComponent=!0},165:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return f}));var r=n(0),a=n.n(r);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var s=a.a.createContext({}),d=function(e){var t=a.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},u=function(e){var t=d(e.components);return a.a.createElement(s.Provider,{value:t},e.children)},b="mdxType",m={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},p=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,o=e.parentName,s=i(e,["components","mdxType","originalType","parentName"]),u=d(n),b=r,p=u["".concat(o,".").concat(b)]||u[b]||m[b]||l;return n?a.a.createElement(p,c(c({ref:t},s),{},{components:n})):a.a.createElement(p,c({ref:t},s))}));function f(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=p;var c={};for(var i in t)hasOwnProperty.call(t,i)&&(c[i]=t[i]);c.originalType=e,c[b]="string"==typeof e?e:r,o[1]=c;for(var s=2;s<l;s++)o[s]=n[s];return a.a.createElement.apply(null,o)}return a.a.createElement.apply(null,n)}p.displayName="MDXCreateElement"},177:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(0),a=n.n(r),l=(n(20),n(413)),o=n(244);const c=e=>{let{type:t,children:n}=e,r=t;return"tip"===t&&(r="success"),"note"===t&&(r="secondary"),a.a.createElement(l.a,{theme:Object(o.b)()},a.a.createElement("div",{className:`admonition admonition-${t} alert alert--${r}`},a.a.createElement("div",{className:"admonition-heading"},a.a.createElement("h5",null,a.a.createElement("span",{className:"admonition-icon"},a.a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"},a.a.createElement("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}))),t.toLowerCase())),a.a.createElement("div",{className:"admonition-content"},a.a.createElement("p",null,n))))},i=()=>a.a.createElement(c,{type:"note"},"See"," ",a.a.createElement("a",{href:"/demos/#demo-environment"},a.a.createElement("b",null,a.a.createElement("i",null,"here")))," ","for more on the ",a.a.createElement("code",null,"GLOBAL_VARS")," we use in our demos")}}]);