This is the continuation of my query,
2. When I clicked the Save button on Please enter reason modal above. The text that I input on the textbox it will save to Remarks
|
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true" Toolbar="Toolbaritems" Height="315">
<GridEvents RowSelected="RowSelectHandler" OnToolbarClick="ToolbarClickHandler" TValue="Order"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" ValidationRules="@(new ValidationRules{ Required=true})" TextAlign="TextAlign.Right" Width="120"></GridColumn>
. ..
</GridColumns>
</SfGrid>
<SfDialog @ref="FirstDialogRef" Width="250px" ShowCloseIcon="true" IsModal="true" @bind-Visible="@IsVisible">
<DialogTemplates>
<Header> Dialog </Header>
<Content>
<div>
<label>Please enter a reason:</label>
<SfTextBox @ref="TextBoxRef" Placeholder='Reason'></SfTextBox>
</div>
</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="Save" IsPrimary="true" OnClick="@SaveDialog" />
<DialogButton Content="Cancel" OnClick="@CancelCloseDialog" />
</DialogButtons>
</SfDialog>
<SfDialog @ref="SecondDialogRef" IsModal="true" Width="285px" Height="215px" Target="#target" ShowCloseIcon="true" @bind-Visible="IsSecondVisible">
<DialogTemplates>
<Header>CPHeader</Header>
<Content>
<p>CPHeader @(TextBoxRef.Value) was archieved</p>
</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="Ok" IsPrimary="true" OnClick="@SecondDlgClick" />
</DialogButtons>
</SfDialog>
<style>
.e-click::before {
content: '\e525';
}
</style>
@code{
SfGrid<Order> Grid;
SfTextBox TextBoxRef;
SfDialog FirstDialogRef;
SfDialog SecondDialogRef;
private List<Object> Toolbaritems = new List<Object>() { "Add", "Edit", "Delete", "Update", "Cancel",
new ItemModel() { Text = "Archive", TooltipText = "Archive", PrefixIcon = "e-click", Id = "Click" } };
public Order SelectedProduct = new Order();
double selectedIndex { get; set; }
public List<Order> Orders { get; set; }
. ..
public void RowSelectHandler(RowSelectEventArgs<Order> args)
{
SelectedProduct = args.Data; //get selected record data
selectedIndex = args.RowIndex; //get selected row index
}
public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
if (args.Item.Id == "Click")
{
var selected = await Grid.GetSelectedRecordsAsync();
if(selected.Count > 0) //check whether anyone of the reocrds are selected or not
{
this.IsFirstVisible= true; //shown dialog
}
}
}
private bool IsFirstVisible { get; set; } = false;
private bool IsSecondVisible { get; set; } = false;
private void SaveDialog()
{
this.IsFirstVisible = false;
this.IsSecondVisible = true;
}
private void CancelCloseDialog()
{
this.IsFirstVisible = false;
}
private async Task SecondDlgClick()
{
SelectedProduct.Remarks = TextBoxRef.Value;
await this.Grid.UpdateRowAsync(selectedIndex, SelectedProduct); // update the row using method
this.IsSecondVisible = false;
}
} |
Here is my code: and still not saving on remarks
<SfGrid DataSource="@CPHeaders"
TValue="CPHeader"
ID="GridHeader"
@ref="GridHeader"
Toolbar="@ToolBarItems"
AllowFiltering="true"
AllowPaging="false"
AllowSorting="true"
AllowTextWrap="true"
AllowResizing="true"
AllowPdfExport="true"
AllowExcelExport="true"
AllowGrouping="true"
AllowSelection="true"
Width="1540px"
Height="460px">
<GridEvents TValue="CPHeader"
RowSelected="RowSelectHandler"
OnActionBegin="ActionBeginHandler"></GridEvents>
<GridEditSettings AllowAdding="true"
AllowDeleting="true"
AllowEditing="true"
Mode="EditMode.Normal"
ShowDeleteConfirmDialog="true">
</GridEditSettings>
<GridEvents OnToolbarClick="ToolbarClickHandler"
OnActionBegin="ActionBeginHandler"
PdfAggregateTemplateInfo="AggregateTemplate"
PdfGroupCaptionTemplateInfo="GroupCaptionHandlerPdf"
ExcelGroupCaptionTemplateInfo="GroupCaptionHandlerExcel"
TValue="CPHeader"></GridEvents>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel"></GridFilterSettings>
<GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Multiple"></GridSelectionSettings>
<GridPageSettings PageSize="15"></GridPageSettings>
@*Header*@
<GridColumns>
<GridColumn Type="ColumnType.CheckBox" Width="70"></GridColumn>
<GridColumn Field=@nameof(CPHeader.Remarks) HeaderText="Remarks"
Visible="@IsShowAll"
Width="150">
<HeaderTemplate>
<div>
<span class="oi oi-project e-icons headericon"></span> Remarks
</div>
</HeaderTemplate>
</GridColumn>
<SfDialog @ref="FirstDialogRef" Width="250px" ShowCloseIcon="true" IsModal="true" @bind-Visible="@IsFirstVisible">
<DialogTemplates>
<Header> Dialog </Header>
<Content>
<div>
<label>Please enter a reason:</label>
<SfTextBox @ref="TextBoxRef" Placeholder='Reason'></SfTextBox>
</div>
</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="Save" IsPrimary="true" OnClick="@SaveDialog" />
<DialogButton Content="Cancel" OnClick="@CancelCloseDialog" />
</DialogButtons>
</SfDialog>
</GridColumns>
<SfGrid>
@code{
public bool IsFirstVisible { get; set; } = false;
public CPHeader SelectedProduct = new CPHeader();
double selectedIndex { get; set; }
public void SaveDialog()
{
this.IsFirstVisible = false;
}
public void CancelCloseDialog()
{
this.IsFirstVisible = false;
}
public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
if (args.Item.Id == "Archive")
{
//Transaction Archive
//ShowDialog = true;
var SelectedRecords = await this.GridHeader.GetSelectedRecords(); //Fetch the selected records
var HeaderID = SelectedRecords[0].CPHeaderID;
var TransNo = SelectedRecords[0].CPNo;
var Remarks = SelectedRecords.Count > 0; //check whether anyone of the reocrds are selected or not
{
this.IsFirstVisible = true; //shown dialog
await this.GridHeader.UpdateRowAsync(selectedIndex, SelectedProduct); // update the row using method
CPHeader = await CPHeaderService.GetCPHeader(Convert.ToInt32(HeaderID));
CPHeader.Status = -1;
await CPHeaderService.UpdateCPHeader(CPHeader);
Confirmation.Show("CPHeader", "CPHeader " + TransNo + " was archived.");
//CPHeaders = (await CPHeaderService.GetCPHeadersByDateRange(FromDateValue, ToDateValue.AddDays(1))).Where(e => e.Status != -1).ToList();
CPHeaders = (await CPHeaderService.GetCPHeaders()).Where(e => e.Status != -1).ToList();
StateHasChanged();
// var rowIndex = await GridHeader.GetRowIndexByPrimaryKeyAsync(SOHeaderID);
}
}
}
public void RowSelectHandler(RowSelectEventArgs<CPHeader> args)
{
SelectedProduct = args.Data; //get selected record data
selectedIndex = args.RowIndex; //get selected row index
}
}
public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
if (args.Item.Id == "Archive")
{
var SelectedRecords = await this.GridHeader.GetSelectedRecords(); //Fetch the selected records
var HeaderID = SelectedRecords[0].CPHeaderID;
var TransNo = SelectedRecords[0].CPNo;
var Remarks = SelectedRecords.Count > 0; //check whether anyone of the reocrds are selected or not
{
this.IsFirstVisible = true; //shown dialog
await this.GridHeader.UpdateRowAsync(selectedIndex, SelectedProduct); // update the row using method
CPHeader = await CPHeaderService.GetCPHeader(Convert.ToInt32(HeaderID));
CPHeader.Status = -1;
await CPHeaderService.UpdateCPHeader(CPHeader);
Confirmation.Show("CPHeader", "CPHeader " + TransNo + " was archived.);
CPHeaders = (await CPHeaderService.GetCPHeaders()).Where(e => e.Status != -1).ToList();
StateHasChanged();
}
}
}
2. All I need is a modal popup that when I clicked the archive It will show "Please enter a reason." Then textbox where I will input a reason why I am going to archive a selected records on the grid. When I click the Save button then it will display to the Remarks.
Is there any update about my query?
|
<SfDialog @ref="FirstDialogRef" Width="250px" ShowCloseIcon="true" IsModal="true" @bind-Visible="@IsFirstVisible">
<DialogTemplates>
<Header> Dialog </Header>
<Content>
<div>
<label>Please enter a reason:</label>
<SfTextBox @ref="TextBoxRef" Placeholder='Reason'></SfTextBox>
</div>
</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="Save" IsPrimary="true" OnClick="@SaveDialog" />
<DialogButton Content="Cancel" OnClick="@CancelCloseDialog" />
</DialogButtons>
</SfDialog>
<SfDialog @ref="SecondDialogRef" IsModal="true" Width="285px" Height="215px" Target="#target" ShowCloseIcon="true" @bind-Visible="IsSecondVisible">
<DialogTemplates>
<Header>CPHeader</Header>
<Content>
<p>CPHeader @(TextBoxRef.Value) was archieved</p>
</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="Ok" IsPrimary="true" OnClick="@SecondDlgClick" />
</DialogButtons>
</SfDialog>
. ..
@code{
SfGrid<Order> Grid;
. ..
private void SaveDialog()
{
this.IsFirstVisible = false;
this.IsSecondVisible = true;
}
private void CancelCloseDialog()
{
this.IsFirstVisible = false;
}
private async Task SecondDlgClick()
{
SelectedProduct.Remarks = TextBoxRef.Value;
await this.Grid.UpdateRowAsync(selectedIndex, SelectedProduct); // update the row using method
this.IsSecondVisible = false;
}
} |