Blazor Table Component with fixed header and columns - html-table

I'm wondering if there's a Blazor component framework just like the Ant design's table component,which has fixed header and columns both sides.
Or can you tell me if there's any method to fix my columns?
My table consists several different self-defined components.These components make up the whole table.Part of the code is as follows.(I use two tables to complete the fixed header function.)
<div id="KeyData" class="text-left table-container">
<div class="head-container text-left">
<table class="head-table" style="border:2px solid black;font-weight:bold;font-size:12px" cellspacing="0" cellpadding="0" border="1" width="#(1000+200*VarientCount)">
<tr class="text-center" style="background-color: #99CCFF;">
<th width="600" colspan="3" rowspan="2">描述 <br> Description </th>
<th width="200" style="background-color: #FFFF99" colspan="#VarientCount">
变量 / Variant
<MatButton OnClick="AddVariant">Add</MatButton>
</th>
<th width="200" rowspan="2">单位 <br> Unit</th>
<th width="200" rowspan="2">备注 <br> Comments</th>
</tr>
<tr class="text-center" style="background-color: #FFFF99">
#for (int i = 0; i < VarientCount; i++)
{
var iCopy = i;
<th width="200">
#(i + 1)
<MatIconButton Icon="clear" OnClick="#(()=>RemoveVariant(iCopy))" Class="after"></MatIconButton>
</th>
}
</tr>
</table>
</div>
<div class="content-container text-left">
<table class="content-table" style="border:2px solid black;font-weight:bold;font-size:12px" cellspacing="0" cellpadding="0" border="1" width="#(1000+200*VarientCount)">
<KeyDataSupplierInfo KeyData="#l_VKDTI_TSI" />
<KeyDataVehicleInfo KeyData="#l_VKDTI_VI" />
<KeyDataDimension KeyData="#l_VKDTI_DIMENSIONS" />
</table>
</div>
</div>
KeyDataSupplierInfo Component as follows(Part code)
<tr>
<td style="background-color: #CCFFFF" width="200" class="text-center" rowspan="8">
Third-party Supplier Info<br>
第三方供应商信息*
</td>
<td style="background-color: #CCFFFF" width="400" class="text-center" colspan="2">
EMS <br>
</td>
#for (int i = 0; i < KeyData.Count; i++)
{
int index = i;
<td width="200" class="text-center bgcolor " >
<MatTextField #bind-Value=#KeyData[index].EMS />
</td>
}
<td style="background-color: #CCFFFF" width="200" class="text-center">
-
</td>
<td style="background-color: #CCFFFF" width="200" class="text-center" rowspan="8">
备注:品牌厂商、软件版本号
</td>
</tr>
<tr>
<td style="background-color: #CCFFFF" width="400" class="text-center" colspan="2">
TCU <br>
</td>
#for (int i = 0; i < KeyData.Count; i++)
{
int index = i;
<td width="200" class="text-center" >
<MatTextField #bind-Value=#KeyData[index].TCU />
</td>
}
<td style="background-color: #CCFFFF" width="200" class="text-center">
-
</td>
</tr>
<tr>
<td style="background-color: #CCFFFF" width="400" class="text-center" colspan="2">
HCU <br>
</td>
#for (int i = 0; i < KeyData.Count; i++)
{
int index = i;
<td width="200" class="text-center" >
<MatTextField #bind-Value=#KeyData[index].HCU />
</td>
}
<td style="background-color: #CCFFFF" width="200" class="text-center">
-
</td>
</tr>

There is a Blazor component library for Ant Design: Ant Design Blazor
It includes the exact table component you are referring to here
Example code with a fixed column and header is as follows:
#using System.ComponentModel
<Table DataSource="data" PageSize="50" ScrollX="1300" ScrollY="240px">
<Column #bind-Field="#context.Name" Width="100" Fixed="left" />
<Column #bind-Field="#context.Age" Width="100" Fixed="left" />
<Column Title="Column 1" #bind-Field="#context.Address" />
<Column Title="Column 2" #bind-Field="#context.Address" />
<Column Title="Column 3" #bind-Field="#context.Address" />
<Column Title="Column 4" #bind-Field="#context.Address" />
<Column Title="Column 5" #bind-Field="#context.Address" />
<Column Title="Column 6" #bind-Field="#context.Address" />
<Column Title="Column 7" #bind-Field="#context.Address" />
<Column Title="Column 8" #bind-Field="#context.Address" />
<ActionColumn Title="Action" Width="100" Fixed="right">
<a>action</a>
</ActionColumn>
</Table>
#code {
class Column
{
[DisplayName("Full Name")]
public string Name { get; set; }
public int Age { get; set; }
public string Address { get; set; }
}
Column[] data = new Column[] {
new()
{
Name = "John Brown",
Age = 32,
Address = "New York Park"
},
new()
{
Name = "Jim Green",
Age = 40,
Address = "London Park"
},
};
}

Related

How to pass value to model (Vuejs 3)

in my Vuejs3 project, there is a form in which the new row will be generated by pressing a button, so I put an array to handle new rows then I need to validate inputs, but after validation of the input of the array, the value didn't pass to model, but it works without the validation.. please help me to understand the mistake that I did.
The Form:
<table class="table table-stripped table-border">
<thead>
<tr>
<th>#</th>
<th style="width: 18%">
Medikament <span class="text-danger">*</span>
</th>
<th style="width: 9%">Milligram</th>
<th style="width: 9%">
Packung <span class="text-danger">*</span>
</th>
<th style="width: 7%">
Stück <span class="text-danger">*</span>
</th>
<th style="width: 19%">Apothekenname</th>
<th style="width: 24%">Adresse der Apotheke</th>
<th style="width: 14%">Postleitzahl</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in patientRequestForCreationDtos" :key="index">
<td>{{ index + 1 }}</td>
<td>
<input type="text" v-model="item.drugName" class="form-control" />
</td>
<td>
<input type="number" v-model="item.milligram" class="form-control" />
</td>
<td>
<input type="number" v-model="item.box" class="form-control" />
</td>
<td>
<input type="number" v-model="item.total" class="form-control" />
</td>
<td>
<input type="text" class="form-control" v-model="item.drugStoreName" :readonly="patientDetails.isElga == false" />
</td>
<td>
<input type="text" class="form-control" v-model="item.drugStoreAddress" :readonly="patientDetails.isElga == false" />
</td>
<td>
<input type="text" class="form-control" v-model="item.drugStorePostalCode" :readonly="patientDetails.isElga == false" />
</td>
<td>
<button type="button" #click="deleteRequestItemRow(index)" class="btn btn-sm btn-danger">
-
</button>
</td>
</tr>
</tbody>
</table>
The Array:
patientRequestForCreationDtos: [{
milligram: null,
box: null,
total: null,
drugStoreName: "",
drugStoreAddress: "",
drugStorePostalCode: "",
drugName: "",
}, ],
The validation function:
checkValidation() {
if (!this.patientRequestForCreationDtos.drugName) {
Swal.fire("drug name is required...");
return;
}
return true;
},
```js
---
it always says => drug name is required..
this.patientRequestForCreationDtos is array. maybe you can do this.
checkValidation(patientRequestForCreationDto) {
if (!patientRequestForCreationDto.drugName) {
Swal.fire("drug name is required...");
return;
}
return true;
},
if you'll have only one element in patientRequestForCreationDtos then you gotta choose first element in the array and then check its property
checkValidation() {
if (!this.patientRequestForCreationDtos[0].drugName) {
Swal.fire("drug name is required...");
return;
}
return true
},
also if your patientRequestForCreationDtos is always gonna be an array then you might find this helpful

Automating using Selenium

I am trying to find the text from the Select Elements "[New List]". The HTML code behind this is :
<div id="pageBody">
<div class="grid">
<div class="col_12 bgColor column">
<form method="POST" action="pickListEdit.cfm" name="formMain" id="formMain">
<input type="hidden" id="usrAction" name="usrAction" value="NONE"/>
<input type="hidden" id="listtype" name="listtype" value="ACCTS"/>
<input type="hidden" id="listmodified" name="listmodified" value="0"/>
<table cellpadding="0" cellspacing="0" border="0" width="620">
<tbody>
<tr class="alt first last">
<td>
<table cellpadding="0" cellspacing="0" border="0" width="360">
<tbody>
<tr class="alt first">
<td width="150" align="right" class="critH2">
<td height="1" align="left">
<select name="listkey" size="1" onchange="formSubmit('GET');"class="selectfont">
<option value="0">[New List]</option>
</select>
</td>
</tr>
<tr class="alt last">
</tbody>
</table>
</td>
<td width="10"/>
<td width="10"/>
<td valign="top">
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="600">
</form>
</div>
</div>
</div>
</div>
</body>
The C# code that I am using is :
var AccPic = Driver.Instance.FindElement(By.ClassName("selectfont"));
var selectelement = new SelectElement(AccPic);
selectelement.SelectByText(AP);
The problem is it is unable to find the field name. What I need to do is find the element [New List] and select it. Can someone please help.
Assuming it's the only option tag on the page:
var newList = Driver.Instance.FindElement(By.TagName("option"));
var selectedElement = new SelectElement(newlist);

Auto login form with Visual Basic

I need make an auto login form application with Visual Basic 10.0 for the following code:
</script>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
<table cellpadding="0" cellspacing="0" border="0" height="100%">
<tr>
<td rowspan="10" width="50%" height="100%" background="images/bg1222.jpg" style="background-position:right top; background-repeat:repeat-y"></td>
<td rowspan="10" width="1" bgcolor="#000000"></td>
<td valign="top">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width=100%>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="778" height="153">
<param name="movie" value="images/hed2.swf">
<param name="quality" value="high">
<embed src="images/hed2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="778" height="153"></embed>
</object>
</td>
</tr>
</table>
</td>
<!--<td rowspan="10" width="0" bgcolor="#000000"></td>-->
<td rowspan="10" width="50%" height="100%" background="images/bg1223.jpg" style="background-position:left top; background-repeat:repeat-y"></td>
</tr>
<tr>
<td width="780" height="30" align="center" valign="bottom" background="images/footer.gif"></td>
</tr>
<tr>
<td height="583" valign="top" style="background-repeat:repeat-y;" >
<br><br><br><br><br><br><br>
<center>
<form action="/cse/login/login1_check.jsp" name="first" method="post">
<table width="25%" height="90" border="0" class='formtable1'>
<caption align="top">
<strong> User Login </strong>
<br>
</caption>
<tr>
</tr>
<tr>
<td width="24%" height="32">
<div align="right"> User ID: </div>
</td>
<td width="76%">
<label>
<input name="uid" type="text" >
</label>
</td>
</tr>
<tr>
<td height="43">
<div align="right"> Password: </div>
</td>
<td>
<label>
<input name="password" type="password" >
</label>
</td>
</tr>
</table>
<input type="submit" name="sub" value="Login">
</form>
</center>`enter code here`
Say username is user and password is pass.
It should be auto filled and clicked in the submit button. What would the code be for Visual Basic 10.0?
Try this:
If Not String.IsNullOrEmpty(My.Settings.Username) And Not String.IsNullOrEmpty(My.Settings.Password) Then
TxtUsername.Text = My.Settings.Username
TxtPassword.Text = My.Settings.Password
End If
You first need to take all the elements that you want to interact to. If they have an ID, you don't need to search, simply get the element with:
Dim elem As HtmlElement = Webbrowser1.Document.GetElementById("myId")
If not, you need to search for yours, for example:
Dim inputs As New List(Of HtmlElement)(a.Document.GetElementsByTagName("input"))
For Each elem As HtmlElement In inputs
If elem.GetAttribute("name").Equals("uid") Then
'...
End If
Next
To set a value of a input:
elem.SetAttributte("value", passwordVar)
To click a clickable element (such a submit input):
elem.InvokeMember("submit")
Or:
elem.InvokeMember("click")

My Google Gadget goes partially out of the screen

When i add this as Gadget to google calendar ,it partially goes out of the screen...How should i correct such that the gadget will appear with in the screen...
Here is a code where it creates a gadget asking for username and password and login button..
I just want to know the procedure too make the gadget to appear with in the screen
enter code here
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="ABC Google Calendar Gadget" width="180" author="abc" author_email="abcgmail.com" description="My First Test">
<Require feature="dynamic-height"/>
<Require feature="google.calendar-0.5"/>
</ModulePrefs>
<Content type="html">
<![CDATA[
<html style="overflow: hidden;">
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<style>
//.login {
// display: block;
//}
//.event {
// display: none;
/}
</style>
</head>
<body class="loc-en ff ff3">
<script>
var _message = 'This is My first Gadget!';
function validateForm(){
alert("Hello");
$('.login').hide();
$('.event').show();
}
function createEventfun(){
alert("create event");
var eventData = {
title: 'NewYear',
details: 'Hi all',
location: 'My room',
allDay: true,
startTime: {year: 2013, month: 04, date: 21},
endTime: {year: 2013, month: 04, date: 22},
attendees: [
{email: 'nirupama.ninusah#gmail.com'}
],
rrule: 'RRULE:FREQ=YEARLY'
};
google.calendar.composeEvent(eventData);
}
function load()
{
alert("Page is loaded");
}
function changeWidth(){
var e1 = document.getElementById("gadgetcell");
e1.style.width = 180;
alert("Page is loaded and width of gadgetcell is modified to 180");
}
</script>
<div class="login" align="left">
<table border="1" height="200" width="100%">
<tr>
<td>
<image src="http://abc.com/Portals/78096/images/abc_logo.jpg" height="60" width="90"/>
</td>
</tr>
<tr>
<td align="left">
<table border="0">
<tr>
<td>Userid</td>
<td><input type="text" name="userid" size=10/><br></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" size=10/><br></td>
</tr>
<tr>
<td>VidyoURL</td>
<td><input type="text" name="url" size=10/><br></td>
</tr>
<tr>
<td><button onClick="validateForm()" style="background-color:red;color:white">LOGIN</button></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div class="event" style="width: 180px;">
<table border="1">
<tr>
<td>
<image src="http://abc.com/Portals/78096/image/abc_logo.jpg" height="60" width="90"/>
</td>
</tr>
<tr>
<td align="center">
<table border="0" height="200" width="100%">
<tr>
<span>User Successfully Aunthenticated</span>
</tr>
<tr>
<button onclick="createEventfun()" style="background-color:red;color:white">CREATE VIDYO EVENT</button>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
]]></Content>
</Module>
Look at Managing Gadget Height:
- A <Require feature="dynamic-height"/> tag (under <ModulePrefs>) to tell the
gadget to load the dynamic-height library.
- A call to the JavaScript function gadgets.window.adjustHeight() whenever there
is a change in content, or another event occurs that requires the gadget to
resize itself.
I added this script to all views and it works:
<script type="text/javascript" charset="utf-8">
function resize(){
gadgets.window.adjustHeight();
}
window.onload=resize;
</script>
Don't forget about "Required feature" tag

Clear input fields onfocus

I'm having problems creating a couple functions to clear an input field onfocus and reset it back to the default text onblur if it's empty. It works fine until you change some of the text and then backspace it out.
My functions are:
function enterField (id, defaultText) {
if (document.getElementById(id).value == defaultText) {
document.getElementById(id).setAttribute("value", "");
document.getElementById(id).style.color = "#000000";
}
}
function leaveField (id, defaultText) {
if (document.getElementById(id).value == "" || document.getElementById(id).value == defaultText) {
document.getElementById(id).setAttribute("value", defaultText);
document.getElementById(id).style.color = "#dddddd";
}
}
And my html is:
<table style="width: 464px; margin-right: -7px; margin-left: -7px; table-layout: fixed;" cellpadding="0" cellspacing="8">
<tr>
<td class="input"><input id="name" type="text" class="name" size="32" value="Name" onfocus="enterField('name', 'Name');" onblur="leaveField('name', 'Name');"></td>
<td class="input"><input id="email" type="text" class="name" size="32" value="Email" onfocus="enterField('email', 'Email');" onblur="leaveField('email', 'Email');"></td>
</tr>
<tr>
<td class="input" colspan="2"><textarea id="message" class="message" rows="8" onfocus="enterField('message', 'Message');" onblur="leaveField('message', 'Message');">Message</textarea></td>
</tr>
<tr>
<td style="text-align: right;" colspan="2"><input id="submit" type="submit" class="button" value="Send"></td>
</tr>
</table>
You can see how it operates at www.ag-designs.ca/index_new.php. Click "Let's Talk" at the bottom.
change
document.getElementById(id).setAttribute("value", defaultText);
to
document.getElementById(id).value = defaultText;
at both occurrences in your functions.