PDA

View Full Version : [CLOSED] spreadsheet selection model pasted rows detection when pasting



Geovision
Jul 28, 2016, 8:06 AM
Hello,
I am using a gridpanel with spreadsheet selection model, I want to copy from an excel file and paste in this gridpanel the problem is if this gridpanel on first load of the page will be holding only one empty row. if I have 5 rows in the excel and I copied it is there any way all the 5 rows pasted to be shown? which means adding automatically the rows to the grid?

Example: I have these 5 rows:
City1 10007395522 1021229881 1021229881
City2 10028238952 157415065 195849401
City3 10026675691 523403688 844342103
City4 10026675691 612204007 86041500
City5 10061386967 610395007 513017040

and this is my Code sample:



<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = new object[]
{
//new object[] { "Dammam", "10007395522", "1021229881", "1021229881" },
new object[] {}
};
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Spreadsheet Selection Model with Clipboard - Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" />

<style>
.x-grid-row-over .x-grid-cell-inner {
font-weight: bold;
}
</style>


</head>
<body>
<ext:ResourceManager runat="server" />


<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Array Grid"
Width="700">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="City" />
<ext:ModelField Name="SAPAccountNb" />
<ext:ModelField Name="SAPSubscriberNumber" />
<ext:ModelField Name="SAPLegacyNumber" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column runat="server" Text="City" DataIndex="City" Flex="1" />
<ext:Column runat="server" Text="SAPAccountNb" DataIndex="SAPAccountNb" />
<ext:Column runat="server" Text="SAPSubscriberNumber" DataIndex="SAPSubscriberNumber">
</ext:Column>
<ext:Column runat="server" Text="SAPLegacyNumber" DataIndex="SAPLegacyNumber">
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:SpreadsheetSelectionModel ID="SpreadsheetSelectionModel1" CheckboxSelect="true" runat="server" />
</SelectionModel>
<Plugins>
<ext:Clipboard ID="Clipboard1" runat="server" />
<ext:RowEditing runat="server" ClicksToMoveEditor="1" AutoCancel="false" />
</Plugins>

</ext:GridPanel>



<ext:Label ID="Label1" runat="server" />
</body>
</html>



I want to copy the 5 rows above into the grid
Note That I dont want to create 5 Empty records because it is not fixed that I will always add 5 records maybe the excel file contains 12 or 40 records

fabricio.murta
Jul 29, 2016, 12:21 AM
Hello!

Sorry, I am afraid it does not really has an auto-row-creation mechanism.

You could do, like MS-Excel does, "preallocate" a number of empty rows to allow pasting but selectively clean empty rows prior to submitting. Either remove the rows client-side before submit, or always submit the rows and exclude de trailing 0-filled (or null) rows. If the amount is going to need to be really flexible, you can add an option to specify how many rows to preallocate to the paste process -- but that's not really user friendly.

Other than that, we could talk about developing a new feature to allow analyzing how many lines are to be pasted and then letting the user preallocate it.

I'll play a little with your test case, if I can find something else interesting about this, I'll update you with the info, but for now, this is what I believe that can be done. Hope this somehow help you with your grid!