Update records in extjs4 grid - extjs4

I am using Extjs4 , I got 1 grid with checkboxes i need to update records selected by user.
I am getting all records selected by user
but problem is its not updating...Code looks as follows
{
xtype: 'button',
text: 'Save/Update',
iconCls : 'icon-save',
handler:function(){
//saveAndUpdate();
var s=grid.getSelectionModel().getSelection();
alert(s.length);
if(s.length==0){
alert(" No Records Selecteds");
}else{
for(var i=0;i<s.length;i++){
var menuKey=s[i].get('menuKey');
var addYN=s[i].get('addYN')==true?'Y':'N';
var editYN=s[i].get('editYN')==true?'Y':'N';
var viewYN=s[i].get('viewYN')==true?'Y':'N';
var deleteYN=s[i].get('deleteYN')==true?'Y':'N';
var exportYN=s[i].get('exportYN')==true?'Y':'N';
alert(menuKey+addYN+editYN+viewYN+deleteYN+exportYN);
var record = Ext.create('RoleMenuLinks');
record.set({
roleKey:roleKey.value,
menuKey:menuKey,
addYN:addYN,
editYN:editYN,
viewYN:viewYN,
deleteYN:deleteYN,
exportYN:exportYN
});
alert("All Record Set ");
tempStore.sync();
}
}
its not calling java controller .... ?

You are creating a record and not putting it anywhere in this code, you need to do something with it:
var record = Ext.create('RoleMenuLinks');
record.set({
roleKey:roleKey.value,
menuKey:menuKey,
addYN:addYN,
editYN:editYN,
viewYN:viewYN,
deleteYN:deleteYN,
exportYN:exportYN
});
// do something with the record here
Or are you supposed to be retrieving a record and updating it? Because this code is not doing that.

Related

How to bring a multi-datatable with pagination,sorting,filtering in single component file in angular 7

I am trying to get multi-table with pagination, sorting, filtering in a single component.
I can get pagination for one table, unable to get pagination for multiple tables in a single component.
I also received the data from all tables. I am receiving the data from the backend so it takes a few seconds.
I Couldn't find any multi-data table example in angular7 material
This is my code
displayedColumns: string[] = ['name', 'id', 'products_count', 'domain'];
public dataSource = new MatTableDataSource<PeriodicElement>(this.ELEMENT_DATA);
public NONAR_ELEMENT_DATA: NonARElement[];
displayedColumns1: string[] = ['pro_id', 'name', 'd_image'];
public dataSource1 = new MatTableDataSource<NonARElement>(this.NONAR_ELEMENT_DATA);
#ViewChild('paginator') paginator: MatPaginator;
#ViewChild('paginator1', { read: MatPaginator }) paginator1: MatPaginator;
_setDataSource(indexNumber) {
console.log("indexNumber", indexNumber)
setTimeout(() => {
switch (indexNumber) {
case 0:
!this.dataSource1.paginator ? this.dataSource1.paginator = this.paginator1 : null;
console.log("this.dataSource-NON AR.paginator", this.dataSource.paginator)
break;
case 1:
!this.dataSource.paginator ? this.dataSource.paginator = this.paginator : null;
console.log("this.dataSource-Storelist.paginator", this.dataSource1.paginator)
}
},1000);
}```
Can you share your html page. Have you used this #name in your paginator?
<mat-paginator #paginator length="100"
pageSize="20"
pageSizeOptions="[10,20,30]"
(page)="pageChanged($event)">
</mat-paginator>
#ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;

second entity query is executed with errors

I have 2 linq queries. First query does nothing because of unique index and this is OK. But second also does nothing while it should add records . If I bypass first query second query works. Should I refresh entity ? How ?
foreach (var product in productList)
{
cc2nexo_SubiektProduct newproduct = new cc2nexo_SubiektProduct();
newproduct.Name = product.Name;
newproduct.VAT = product.VAT;
newproduct.Id = product.Id;
foreach (var stawkaVAT in myNexo_ExitoEntities.StawkiVat)
{
if (stawkaVAT.Stawka * 100 == tryconvert_dec(newproduct.VAT))
{
newproduct.VAT_Id = stawkaVAT.Id;
}
}
myNexo_ExitoEntities.cc2nexo_SubiektProduct.Add(newproduct);
SurroundWithTryCatchDB(() =>
{
myNexo_ExitoEntities.SaveChanges();
});
}
var orders = (from myorders in myNexo_ExitoEntities.temp_SubiektOrderList
select myorders).ToList();
foreach (var order in orders)
{
cc2nexo_SubiektOrderList neworder = new cc2nexo_SubiektOrderList();
neworder.Data_utworzenia_sprawy = tryconvert_date(order.Data_utworzenia_sprawy);
neworder.Data_modyfikacji_sprawy = tryconvert_date(order.Data_modyfikacji_sprawy);
neworder.Data_umowy = tryconvert_date(order.Data_umowy);
neworder.Id = order.Id;
myNexo_ExitoEntities.cc2nexo_SubiektOrderList.Add(neworder);
SurroundWithTryCatchDB(() =>
{
myNexo_ExitoEntities.SaveChanges();
});
Debug.WriteLine(neworder.LastName);
}
I am receiving an error
Cannot insert duplicate key row in object 'dbo.cc2nexo_SubiektProduct' with unique index 'K_ID'. The duplicate key value is (1).The statement has been terminated
The reason of problem was SurroundWithTryCatchDB procedure not listed in my question. Because first query caused exception due to unique index all next SaveChanges did not work. I have changed my first query to work with unique values and now everything is OK.

Ext.NET MultiCombo not firing event after de-selecting last item

Below is the razor markup, that i am using to get Ext.NET MultiCombo as shown in attached image
Html.X().MultiComboFor(x => x.CountryCodes).MultiSelect(true)
.Editable(false)
.QueryMode(DataLoadMode.Local)
.TriggerAction(TriggerAction.All)
.DisplayField("COUNTRY_DESC")
.ValueField("COUNTRY_CD")
.LabelWidth(80)
.FieldLabel(PR.Resources.IP.IP.Country)
.Listeners(ls => { ls.Select.Handler = "setCountryCodes();return false;"; ls.Change.Handler = "return false;"; })
.Store(Html.X().Store()
.ID("storeListCountryForPTOTR")
.AutoLoad(false)
.Model(Html.X().Model()
.IDProperty("COUNTRY_CD")
.Fields(
new ModelField("COUNTRY_CD", ModelFieldType.String) { Mapping = "COUNTRY_CD" },
new ModelField("COUNTRY_DESC", ModelFieldType.String) { Mapping = "COUNTRY_DESC" }
)
)
.Proxy(Html.X().AjaxProxy()
.Url(Url.Action("GetPriceTrendCountryForCountryDropdown", "InternalPricing")).ActionMethods(methods =>
methods.Read = HttpMethod.POST
).Reader(Html.X().JsonReader().Root("data"))
)
)
As shown in markup i am handling Select event on checkbox check/uncheck.
but this event is not getting fired when i Un-Check remaining item from list.
What could be the reason that MultiCombo is not firing the event for last item uncheck?
The Select event is meant to fire on selecting an item only, not on deselecting.
Probably, MultiCombo's Change event is what you need.

How to Set title and delete dijit.form.select in tablecontainer

I'm creating a table container, to which i'm adding select widget,
var layout1 = new dojox.layout.TableContainer({
showLabels: true,
orientation: "horiz",
cols : 2,
spacing: 5,
style: "border: solid 1px LightBlue;",
customClass : "tableContainer"
});
layout.placeAt(divContentNode);
Below is my select widget:
var ran = new dijit.form.Select(
{
id :"srz102" ,
name : "ZEND100",
title : "VAPORTforVA",
maxHeight : '100',
style:"width: 150px",
required:true,
options:v4
}
);
layout1.addChild(ran);
But with this i didn't get title for select widget,so i added
layout1.layout();
which displayed the title for select widget
Now when i try to destroy select widget i'm not able to delete the title
dijit.byId("srz102").destroyRecursive();
I guess you trying to get hold of select node and destroying. That's why your title is not deleting properly. Instead you should try catching its parent and then try destroying the child
If you are using dojo 1.7 + (AMD), you can use:
require(["dojo/dom-construct"], function(domConstruct){
// Destroy a node byId:
domConstruct.destroy("id");
})
For recursive deletion you can use :
dojo.query("id").forEach(dojo.destroy);
However you need to traverse the parent dom-node and delete each of them.
Just FYI dojo.query is very useful to get hold of any node not limited to id, you can get hold through css class like below
dojo.query(".cssClass")
Further ref :http://dojotoolkit.org/reference-guide/1.7/dojo/destroy.html

SQL to Insert data into multiple tables from one POST in WebMatrix Razor Syntax

I've got two form fields from which the user submits a 'category' and an 'item'.
The following code inserts the category fine (I modified it from the WebMatrix intro PDF) but I've no idea how to then insert the 'item' into the Items table. I'll also need to add the Id of the new category to the new item row.
This is the code that's working so far
#{ var db = Database.OpenFile("StarterSite.sdf");
var Category = Request["Category"]; //was name
var Item = Request["Item"]; //was description
if (IsPost) {
// Read product name.
Category = Request["Category"];
if (Category.IsEmpty()) {
Validation.AddFieldError("Category", "Category is required");
}
// Read product description.
Item = Request["Item"];
if (Item.IsEmpty()) {
Validation.AddFieldError("Item",
"Item type is required.");
}
// Define the insert query. The values to assign to the
// columns in the Products table are defined as parameters
// with the VALUES keyword.
if(Validation.Success) {
var insertQuery = "INSERT INTO Category (CategoryName) " +
"VALUES (#0)";
db.Execute(insertQuery, Category);
// Display the page that lists products.
Response.Redirect(#Href("~/success"));
}
}
}
I'm guessing/hoping this is a very easy question to answer so hopefully there isn't much more detail required - but please let me know if there is. Thanks.
There's a Database.GetLastInsertId method within WebMatrix which returns the id of the last inserted record (assuming it's an IDENTITY column you are using). Use that:
db.Execute(insertQuery, Category);
var id = (int)db.GetLastInsertId(); //id is the new CategoryId
db.Execute(secondInsertQuery, param1, id);