问题
I created print the address in list view of custom leads the list view code is as given below.
There are 25 records totally first i select 20 records(select this page) ,its performing the action for 20 records which is correct if i seelct all its performing action for only 20 records ,so its not selecting the 25 records ...
protected function buildMyMenuItem()
{
global $app_strings;
return <<<EOHTML
<a class="menuItem" style="width: 150px;" href="#" onmouseover='hiliteItem(this,"yes");'
onmouseout='unhiliteItem(this);'
onclick="sugarListView.get_checks();
if(sugarListView.get_checks_count() < 1) {
alert('{$app_strings['LBL_LISTVIEW_NO_SELECTED']}');
return false;
}
document.MassUpdate.action.value='print';
document.MassUpdate.submit();">Print Label</a>
EOHTML;
}
Im calling it in the controller class below is the code
class CustomLeadsController extends SugarController
{
public function action_print() {
if ( !empty($_REQUEST['uid']) ) {
$recordIds = explode(',',$_REQUEST['uid']);
print_r($recordIds);
?>
<form>
<div align="right">
<input name="button" type="button" onclick="window.print()" value="print" />
</div>
</form>
<table width="1024px" border="1" cellspacing="1" cellpadding="1" style="border-collapse:collapse;">
<?php
$i = 0;
foreach ($recordIds as $recordId )
{
$bean = SugarModule::get($_REQUEST['module'])->loadBean();
// print_r($bean);
$bean->retrieve($recordId);
if ($i % 4 == 0)
{
echo '<tr>';
}
?>
<td align="left" width="25%" height="100px" STYLE="font-family: 'comic sans ms', fantasy; padding:10px; font-size:12px;">
<?php echo $bean->get_summary_text(); ?>
<br>
<?php echo nl2br($bean->primary_address_street); ?>
<?php
if($bean->primary_address_city != "")
{
echo "<br>";
echo nl2br($bean->primary_address_city);
}
?>
<br>
<?php echo nl2br($bean->primary_address_state); ?>
<br>
<?php echo nl2br($bean->primary_address_postalcode); ?>
</td>
<?php
if ($i % 4 == 3)
{
echo '</tr>';
}
$i++;
}
//here is a check in case you don't have multiple of 3 rows
if ($i % 4 != 0)
{
echo '</tr>';
}
?>
</table>
<?php
}
sugar_die('');
}
}
回答1:
I ran into a similar issue a while ago, $_REQUEST['uid']
only shows items selected on the page, not the full filtered list.
Check if the entire list has been selected, $_REQUEST['select_entire_list'] == 1
Get the query that that has created the filtered list - $_REQUEST['current_query_by_page']
You can then use the Mass Update class to get a list of all the selected records
$mass = new MassUpdate();
$mass->setSugarBean($bean);
$mass->generateSearchWhere($module, $_REQUEST['current_query_by_page']);
$seed = BeanFactory::getBean($module);
$query = $seed->create_new_list_query('name ASC', $mass->where_clauses);
$result = $db->query($query, true);
回答2:
Instead you could use a script function for getting all the selected check-boxes from all pages of the records as follows :
sugarListView.get_checks();
var v = document.MassUpdate.uid.value;
alert("V : "+v);
回答3:
This can be done using the $_SESSION global in PHP if you don't want to use the bean. This can be particularly useful to change a large number of records quickly. You need to change the module name in the ['Module2_Query'] index.
This returns the full query for whatever search was entered in the filter. At that point you just use the global $db to get the values you need.
if($_REQUEST['select_entire_list'] == 1) {
$searchQuery = $_SESSION['Leads2_QUERY'];
}
来源:https://stackoverflow.com/questions/21971086/sugarcrm-custom-module-select-all-across-multiple-page