/// <summary> /// Registers the java script for grid actions. /// NOTE: This needs to be done after the BindGrid /// </summary> private void RegisterJavaScriptForGridActions() { string scriptFormat = @" $('#{0}').change(function( e ){{ var count = $(""#{1} input[id$='_cbSelect_0']:checked"").length; if (count == 0) {{ eval({2}); }} else {{ var $ddl = $(this); if ($ddl.val() != '') {{ Rock.dialogs.confirm('Are you sure you want to ' + ($ddl.val() == 'OPEN' ? 'open' : 'close') + ' the selected batches?', function (result) {{ if (result) {{ eval({2}); }} $ddl.val(''); }}); }} }} }});"; string script = string.Format(scriptFormat, ddlAction.ClientID, gBatchList.ClientID, Page.ClientScript.GetPostBackEventReference(this, "StatusUpdate")); ScriptManager.RegisterStartupScript(ddlAction, ddlAction.GetType(), "ConfirmStatusChange", script, true); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); var contextEntity = this.ContextEntity(); if (contextEntity != null) { if (contextEntity is Person) { _person = contextEntity as Person; } else if (contextEntity is FinancialBatch) { _batch = contextEntity as FinancialBatch; gfTransactions.Visible = false; } else if (contextEntity is FinancialScheduledTransaction) { _scheduledTxn = contextEntity as FinancialScheduledTransaction; gfTransactions.Visible = false; } else if (contextEntity is Registration) { _registration = contextEntity as Registration; gfTransactions.Visible = false; } } if (!Page.IsPostBack) { BindFilter(); BindGrid(); } if (_canEdit && _batch != null) { string script = string.Format(@" $('#{0}').change(function( e ){{ var count = $(""#{1} input[id$='_cbSelect_0']:checked"").length; if (count == 0) {{ eval({2}); }} else {{ var $ddl = $(this); if ($ddl.val() != '') {{ Rock.dialogs.confirm('Are you sure you want to move the selected transactions to a new batch (the control amounts on each batch will be updated to reflect the moved transaction\'s amounts)?', function (result) {{ if (result) {{ eval({2}); }} $ddl.val(''); }}); }} }} }}); ", _ddlMove.ClientID, gTransactions.ClientID, Page.ClientScript.GetPostBackEventReference(this, "MoveTransactions")); ScriptManager.RegisterStartupScript(_ddlMove, _ddlMove.GetType(), "moveTransaction", script, true); } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); bool promptWithFilter = true; var contextEntity = this.ContextEntity(); if (contextEntity != null) { if (contextEntity is Person) { _person = contextEntity as Person; promptWithFilter = false; } else if (contextEntity is FinancialBatch) { _batch = contextEntity as FinancialBatch; gfTransactions.Visible = false; promptWithFilter = false; } else if (contextEntity is FinancialScheduledTransaction) { _scheduledTxn = contextEntity as FinancialScheduledTransaction; gfTransactions.Visible = false; promptWithFilter = false; } } if (!Page.IsPostBack) { BindFilter(); if (promptWithFilter && gfTransactions.Visible) { //// NOTE: Special Case for this List Block since there could be a very large number of transactions: //// If the filter is shown and we aren't filtering by anything else, don't automatically populate the grid. Wait for them to hit apply on the filter gfTransactions.Show(); } else { BindGrid(); } } if (_canEdit && _batch != null) { string script = string.Format(@" $('#{0}').change(function( e ){{ var count = $(""#{1} input[id$='_cbSelect_0']:checked"").length; if (count == 0) {{ eval({2}); }} else {{ var $ddl = $(this); if ($ddl.val() != '') {{ Rock.dialogs.confirm('Are you sure you want to move the selected transactions to a new batch (the control amounts on each batch will be updated to reflect the moved transaction\'s amounts)?', function (result) {{ if (result) {{ eval({2}); }} $ddl.val(''); }}); }} }} }}); ", _ddlMove.ClientID, gTransactions.ClientID, Page.ClientScript.GetPostBackEventReference(this, "MoveTransactions")); ScriptManager.RegisterStartupScript(_ddlMove, _ddlMove.GetType(), "moveTransaction", script, true); } }