excelstyles values in exportOptions aren't working? - angular-ui-bootstrap

This seems like the correct way to set the exportOptions object properties, but it's not working for me. Can someone explain why?
exportOptions:{
ignoreColumn: [0,0],
fileName: '阅卷结果',
worksheetName: 'sheet1',
tableName: '阅卷结果',
excelstyles: ['background-color', 'color', 'font-size', 'font-weight']
}

Related

Need assistance reading the object returned by getRowId of MaterialReactTable

I am using MaterialReactTable in my application and following the Row Selection Option as outlined at this link: https://www.material-react-table.com/docs/guides/row-selection
The table is working fine and I am able to select the row I want and it returns the correct id but returns it in the format: rowSelection = {63d19bebc764a5587a48683a: true}. I am not familiar with this format.
I have tried everything I know but am unable to parse out the id from the object.
Please provide suggestion to parse out the id or suggest changes to make this solution work.
I have tried the other methods of row selection suggested on the page (useRef and '#tanstack/react-table') and could not get either to work so would like to stick to this method as I feel it is close.
Below is the code and options I am using with the MaterialReactTable
return (
<MaterialReactTable
columns={columns}
data={data}
enableRowSelection
onRowSelectionChange={setRowSelection}
enableMultiRowSelection={false}
//getRowId={(row) => row?._id }
getRowId={(originalRow) => originalRow._id}
initialState={{ showColumnFilters: true,
columnVisibility:
{ _id: false } }} //hide columns listed to start }}
manualFiltering
manualPagination
manualSorting
muiToolbarAlertBannerProps={
isError
? {
color: 'error',
children: 'Error loading data',
}
: undefined
}
muiTableBodyRowProps={({ row }) => ({
//add onClick to row to select upon clicking anywhere in the row
onClick: row.getToggleSelectedHandler(),
sx: { cursor: 'pointer' },
})}
onColumnFiltersChange={setColumnFilters}
onGlobalFilterChange={setGlobalFilter}
onPaginationChange={setPagination}
onSortingChange={setSorting}
rowCount={rowCount}
state={{
columnFilters,
globalFilter,
isLoading,
pagination,
showAlertBanner: isError,
showProgressBars: isRefetching,
sorting,
rowSelection
}}
/>
);
Given the format of the response, rowSelection = {63d19bebc764a5587a48683a: true}, I had originally assumed a key: value pair with the id being the key. My initial attempts to parse out the id as the key had failed. After trying a number of different options, I was able to use the Object.keys() function as follows:
console.log(Object.keys(rowSelection)); //used to view the key(s) returned
setCurrentRoom(Object.keys(rowSelection));
This code converted the id to a string in an array as follows: currentRoom = ['63d19bd9c764a5587a486836']

easyui edatagrid Set Default Value for Numberbox

Can anyone help me with a problem I am having. I'm using JEasyUI eDataGrid, and when inserting a new record I would like the numberbox fields to automatically have a 0 in them.
Table portion
<th field="Defect" width="50">Defect</th>
Script
$(function(){
$('#dg').edatagrid({
url: ...
emptyMsg: 'No Record(s) Found',
columns:[[
{field:'Defect',title:'Defect',width:100,
formatter:function(value,row){
return row.Defect|| value;
},
editor:{
type:'numberbox',
options:{
required:true,
min:0,
*value: 0,*
}
Looking through the documentation, adding a value property should set a default value but it does not.
Figured out the answer. What I needed to do was add the following to my script.
onBeginEdit: function(index,row){
var ed = $(this).datagrid('getEditor',{index:index,field:'defect'});
$(ed.target).numberbox('setValue', 0)
},

adding value for map which is key of other map in DART

I have a map like this,
"data":{
"date":"Date",
"time":"Time",
"from":"From",
"to":"To",
"color":"Color",
"state":"State",
"country":"Country"
},
I want to create another map that should look like this,
map header;
which should contain,
header {
"1":"date",
"2":"time",
"3":"from",
"4":"to",
"5":"color",
"6":"state",
"7":"country",
}
I am not getting how to add the key of another map as a value to header map, and also adding key starts form 1.
can anyone help me on this
thanks
In Dart, you can do something like this.
var header = data.keys.toList().asMap().map((index, value)=> MapEntry(index+1, value));
Here is another way to achieve that:
var i = 1;
Map.fromIterable(data.keys, key: (_) => i++);

Nested includes with where on Rails

Lets say we have 3 tables:
products (title, product_type_id)
product_types (title)
product_type_options (product_type_id, size)
I want to load product, its type & ONLY specific product_type_options (product_type_options.size = 'XL')
Is it possible to do without N+1 query in rails?
Something like:
Product.includes( product_type: [product_type_options] )
.where("product_type_options.size = 'XL'")
I can not it get it to work with where parameter. Any idea?
This should work
Product.includes(product_type: :product_type_options)
.where(product_types: { product_type_options: { size: 'XL' } })
#Iceman was close... the reason it's not seeing 'product_types' is because it needs to be represented as an explicit hash inside the where clause, then Ruby will do the proper nesting...
Product.includes(product_type: :product_type_options)
.where({ product_types: { product_type_options: { size: 'XL' } } })
Strange, but adding the extra {} in the where clause makes the nested includes work.
Please try this, this is a small syntax change. I have not tested it. Let me know if it works :)
Product.includes( product_type: [product_type_options] )
.where("product_type_options.size" => 'XL')

Set the value of an ExtJS ComboBox to an Object, not an object property

I have a ComboBox in an EditorGrid. I am populating it (trying) using JSON, which is produced by serializing an IList<FertilizerType>. I want the valueField of the ComboBox to be equal to the FertilizerType objects and the displayField equal to FertilizerType.Name
Here is a Crop:
{\"Id\":1300,\"Active\":true,\"Code\":\"Ammonium Bicarbonate\",\"Description\":\"Ammonium Bicarbonate\",\"GroupName\":\"FertilizerType\",\"Name\":\"Ammonium Bicarbonate\",\"Ordinal\":1}
Why do I want to set the valueField to an object you might ask? Well, all the data in the grid is part of a Crop object. The ComboBox needs to return a FertilizerType so that Crop.FertilizerType can be populated.
Here is my Column definition:
{
header: 'Fertilizer Type',
dataIndex: 'FertilizerType',
width: 170,
editor: new Ext.form.ComboBox({
store: new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: Cbp.baseUrl + 'Controller/GetFertilizerTypes'
}),
reader: new Ext.data.JsonReader({}, ['FertilizerType', 'FertilizerType.Name']),
remoteSort: false
}),
valueField: 'FertilizerType',
displayField: 'FertilizerType.Name',
hiddenName: 'FertTypeObject',
mode: 'remote',
minChars: 0
})
}
Thanks for any help! This is driving me nuts!
I solved this problem by replicating the C# objects in javascript. Now they post to the server correctly.

Resources