-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path631872b2.c7a286bc.js
1 lines (1 loc) · 8.02 KB
/
631872b2.c7a286bc.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[30],{103:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return l})),n.d(t,"metadata",(function(){return c})),n.d(t,"toc",(function(){return o})),n.d(t,"default",(function(){return b}));var a=n(3),r=(n(0),n(165));n(179);const l={id:"basic",title:"Summary Row"},c={unversionedId:"Summaryrow/basic",id:"Summaryrow/basic",isDocsHomePage:!1,title:"Summary Row",description:"material-table-core supports a summary row.",source:"@site/demos/Summaryrow/basic.mdx",slug:"/Summaryrow/basic",permalink:"/demos/Summaryrow/basic",version:"current",sidebar:"sidebar",previous:{title:"Cell Validation",permalink:"/demos/validation/basic"},next:{title:"Basic Pagination Demo",permalink:"/demos/pagination/basic"}},o=[{value:"The function will be called with following parameters for each column:",id:"the-function-will-be-called-with-following-parameters-for-each-column",children:[]},{value:"The function can return a value and optional styles for cell that should display a value in the summary row:",id:"the-function-can-return-a-value-and-optional-styles-for-cell-that-should-display-a-value-in-the-summary-row",children:[]},{value:"Examples",id:"examples",children:[]}],i={toc:o};function b(e){let{components:t,...n}=e;return Object(r.b)("wrapper",Object(a.a)({},i,n,{components:t,mdxType:"MDXLayout"}),Object(r.b)("p",null,"material-table-core supports a summary row."),Object(r.b)("table",null,Object(r.b)("thead",{parentName:"table"},Object(r.b)("tr",{parentName:"thead"},Object(r.b)("th",{parentName:"tr",align:null},"Field"),Object(r.b)("th",{parentName:"tr",align:null},"Type"),Object(r.b)("th",{parentName:"tr",align:null}))),Object(r.b)("tbody",{parentName:"table"},Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",{parentName:"tr",align:null},Object(r.b)("inlineCode",{parentName:"td"},"renderSummaryRow")),Object(r.b)("td",{parentName:"tr",align:null},"func"),Object(r.b)("td",{parentName:"tr",align:null},"The function to create the summary row")))),Object(r.b)("h3",{id:"the-function-will-be-called-with-following-parameters-for-each-column"},"The function will be called with following parameters for each column:"),Object(r.b)("table",null,Object(r.b)("thead",{parentName:"table"},Object(r.b)("tr",{parentName:"thead"},Object(r.b)("th",{parentName:"tr",align:"center"},"parameter"),Object(r.b)("th",{parentName:"tr",align:"center"},"Type"),Object(r.b)("th",{parentName:"tr",align:null}))),Object(r.b)("tbody",{parentName:"table"},Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",{parentName:"tr",align:"center"},Object(r.b)("inlineCode",{parentName:"td"},"columns")),Object(r.b)("td",{parentName:"tr",align:"center"},"Colum[]"),Object(r.b)("td",{parentName:"tr",align:null},"All columns of the table")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",{parentName:"tr",align:"center"},Object(r.b)("inlineCode",{parentName:"td"},"column")),Object(r.b)("td",{parentName:"tr",align:"center"},"Column"),Object(r.b)("td",{parentName:"tr",align:null},"The column to render the cell of")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",{parentName:"tr",align:"center"},Object(r.b)("inlineCode",{parentName:"td"},"index")),Object(r.b)("td",{parentName:"tr",align:"center"},"number"),Object(r.b)("td",{parentName:"tr",align:null},"The index of the current column")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",{parentName:"tr",align:"center"},Object(r.b)("inlineCode",{parentName:"td"},"data")),Object(r.b)("td",{parentName:"tr",align:"center"},"RowData[]"),Object(r.b)("td",{parentName:"tr",align:null},"All data of the table")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",{parentName:"tr",align:"center"},Object(r.b)("inlineCode",{parentName:"td"},"currentData")),Object(r.b)("td",{parentName:"tr",align:"center"},"RowData[]"),Object(r.b)("td",{parentName:"tr",align:null},"The data currently displayed on the page")))),Object(r.b)("h3",{id:"the-function-can-return-a-value-and-optional-styles-for-cell-that-should-display-a-value-in-the-summary-row"},"The function can return a value and optional styles for cell that should display a value in the summary row:"),Object(r.b)("table",null,Object(r.b)("thead",{parentName:"table"},Object(r.b)("tr",{parentName:"thead"},Object(r.b)("th",{parentName:"tr",align:null},"Field"),Object(r.b)("th",{parentName:"tr",align:null},"Type"),Object(r.b)("th",{parentName:"tr",align:null}))),Object(r.b)("tbody",{parentName:"table"},Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",{parentName:"tr",align:null},Object(r.b)("inlineCode",{parentName:"td"},"value")),Object(r.b)("td",{parentName:"tr",align:null},"React.ReactNode"),Object(r.b)("td",{parentName:"tr",align:null},"The value to print in the given cell of the summary row")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",{parentName:"tr",align:null},Object(r.b)("inlineCode",{parentName:"td"},"style")),Object(r.b)("td",{parentName:"tr",align:null},"React.CSSProperties"),Object(r.b)("td",{parentName:"tr",align:null},"Optional css properties to style the cells")))),Object(r.b)("h3",{id:"examples"},"Examples"),Object(r.b)("pre",null,Object(r.b)("code",{parentName:"pre",className:"language-jsx",metastring:"live",live:!0},'function SummaryTable() {\n const data = [\n { name: "Engel", surname: "Dominik", age: 27 },\n { name: "Seb", surname: "Teko", age: 24 },\n ];\n const columns = [\n {\n title: "Name",\n field: "name",\n },\n {\n title: "Surname",\n field: "surname",\n },\n {\n title: "Age",\n field: "age",\n type: "numeric",\n },\n ];\n return (\n <MaterialTable\n data={data}\n columns={columns}\n renderSummaryRow={({ column, data }) =>\n column.field === "age"\n ? {\n value: data.reduce((agg, row) => agg + row.age, 0),\n style: { background: "red" },\n }\n : undefined\n }\n />\n );\n}\n')))}b.isMDXComponent=!0},165:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return O}));var a=n(0),r=n.n(a);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 c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(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,a,r=function(e,t){if(null==e)return{};var n,a,r={},l=Object.keys(e);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var b=r.a.createContext({}),m=function(e){var t=r.a.useContext(b),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},u=function(e){var t=m(e.components);return r.a.createElement(b.Provider,{value:t},e.children)},p="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},s=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,l=e.originalType,c=e.parentName,b=i(e,["components","mdxType","originalType","parentName"]),u=m(n),p=a,s=u["".concat(c,".").concat(p)]||u[p]||d[p]||l;return n?r.a.createElement(s,o(o({ref:t},b),{},{components:n})):r.a.createElement(s,o({ref:t},b))}));function O(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var l=n.length,c=new Array(l);c[0]=s;var o={};for(var i in t)hasOwnProperty.call(t,i)&&(o[i]=t[i]);o.originalType=e,o[p]="string"==typeof e?e:a,c[1]=o;for(var b=2;b<l;b++)c[b]=n[b];return r.a.createElement.apply(null,c)}return r.a.createElement.apply(null,n)}s.displayName="MDXCreateElement"}}]);